-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce charge particle warnings; add static particle_charge method #1109
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Oops, looks like this branch contains a bunch of old commits...but it looks like everything is caught up with the main branch except for the new changes. Here is a quick example:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to do the trick. Are there any other instances where we're having the charge error pop up? I think sometimes I see it when I try to convert to gmso.
Also, now we have some failing tests, so have to spend some time to look and see whats going on there. Looks like:
mbuild/tests/test_compound.py::TestCompound::test_none_charge
mbuild/tests/test_compound.py::TestCompound::test_resnames_parmed_cg
The test none_charge should be where you put the different functions you've mentioned and check for either catching or not catching the warnings. This test seems to show some weird behavior. If you start with a compound with mass 2, then you add a port to it, the compound changes it's nature: def test_mass_add_port(self):
A = mb.Compound(mass=2.0)
print(A)
A.add(mb.Port())
print(A)
assert A.mass == 2.0 Output
Not entirely sure what to make of it. |
I think maybe the better fix would be adding a conditional to The default behavior is to have an empty OrderSet:
Possible Fix:
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1109 +/- ##
=======================================
Coverage 89.50% 89.51%
=======================================
Files 61 61
Lines 6305 6311 +6
=======================================
+ Hits 5643 5649 +6
Misses 662 662
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
PR Summary:
I am getting an insane amount charge not set warnings when performing tasks like
compound.visualize()
or usingfill_box
. I'm pretty sure what was happening isconversion.py
is accessing thecharge
property at the particle level, and warnings are being thrown each time.This PR adds a static method for a particle charge (same thing we do for mass). This way, the charge not set warning is not raised if being called on a particle. The warning is still raised if the compound contains children, which is really where we want the warning (summing over particle charges to return a single value)
PR Checklist