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
AtomGroup.center fails for compounds+wrapping #2984
Comments
Because we're still fixing 1.0.x, it is a lot easier if bug fixes are separate from enhancements of any kind. We have no problem adding performance enhancements back into 1.x but in general, micro PRs are easier to handle because sometimes the discussion on something that looked like an obvious thing leads us to a more nuanced view. |
So, when testing, I realized this bug is more serious than I first thought: When But rather than just impacting center calculations when unwrapping + unordered compounds, this bug introduces a mismatch between the weight sorting (which always happens) and coordinate sorting (which isn't happening for unwrap). This means that all The upcoming PR with a fix ensures coordinates are sorted in tandem with weights. It also introduces a check if sorting really is needed: it's an expensive operation, and, in this case, unnecessarily broadened the impact of the bug. |
Just an update on some further checks: the bug with |
… with unwrapping (PR MDAnalysis#2992) fixes MDAnalysis#2984 (cherry picked from commit beb5232)
… with (MDAnalysis#2992) unwrapping (closes MDAnalysis#2984).
Digging into the optimization of
AtomGroup.unwrap
(from the discussion in #2982) I am trying to replicate the vectorization done inAtomGroup.center
. I noticed that in there there's a sorting of compound indices that isn't being done if the user requests compound unwrapping. This breaks center calculation if for some reason a compound's atoms are not initially contiguous.This is a corner case, but still possible. The fix is quite simple, and if it's ok with you I'd include it in the upcoming PR dedicated to the wrap/unwrap enhancement because that will also be dealing with similar code patterns, in the same source file (
core/groups.py
).Code to reproduce the behavior
With a simple 5-water system:
The fragment COGs of the test group:
Same answer if atoms are unwrapped but consecutive (molecules are already whole in this test traj):
Also ok if randomized but not unwrapped:
Oops!
Current version of MDAnalysis
2.0.0-dev0
(at commit 64a7c05), Python 3.6.9, Ubuntu 18.04EDIT: output clarification
The text was updated successfully, but these errors were encountered: