-
Notifications
You must be signed in to change notification settings - Fork 764
FIX: Handle a non-linear FrameIterator in HydrogenBondAnalysis #5202
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
base: develop
Are you sure you want to change the base?
FIX: Handle a non-linear FrameIterator in HydrogenBondAnalysis #5202
Conversation
|
Oops it seems like my auto-formatter went a bit wild - despite still passing Black. Will clean up. |
695a668 to
84e63d2
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5202 +/- ##
========================================
Coverage 92.72% 92.73%
========================================
Files 180 180
Lines 22473 22476 +3
Branches 3189 3190 +1
========================================
+ Hits 20838 20843 +5
+ Misses 1177 1176 -1
+ Partials 458 457 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
orbeckst
left a comment
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.
Looks good!
Optionally: Look at the performance, perhaps there's a faster way to do the lookup.
| count_lookup = dict(zip(indices, tmp_counts)) | ||
| return np.array([count_lookup.get(i, 0) for i in range(len(self.frames))]) |
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.
Looking up each frame looks slow. Perhaps there's some numpy magic (take???) ?
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.
The only really faster approach I could figure out would be this:
if self.start is None:
counts = np.zeros(len(self.frames), dtype=int)
positions = np.searchsorted(self.frames, indices)
counts[positions] = tmp_counts
return countsBut this assumes the self.frames to be sorted. Would this always be the case, given the FrameIterator could be a non-sorted sequence of frames?
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.
I am not sure if self.frames is sorted, possibly not when using run(frames=[2, 3, 0, 7, 6]). Maybe do a quick test?
Perhaps one could sort frames and rearrange counts in the same way and then un-sort everything again before returning?
Fixes #5200
Changes made in this Pull Request:
self.startis None then return computed values by using a dictionary lookup rather than index lookupLLM / AI generated code disclosure
LLMs or other AI-powered tools (beyond simple IDE use cases) were used in this contribution: no
PR Checklist
package/CHANGELOGfile updated?package/AUTHORS? (If it is not, add it!)Developers Certificate of Origin
I certify that I can submit this code contribution as described in the Developer Certificate of Origin, under the MDAnalysis LICENSE.
📚 Documentation preview 📚: https://mdanalysis--5202.org.readthedocs.build/en/5202/