-
Notifications
You must be signed in to change notification settings - Fork 764
nojump.py raises a valueerror when applied not at first frame #5201
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5201 +/- ##
===========================================
- Coverage 92.72% 92.72% -0.01%
===========================================
Files 180 180
Lines 22474 22475 +1
Branches 3189 3190 +1
===========================================
Hits 20840 20840
- Misses 1176 1177 +1
Partials 458 458 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| ValueError, match="must be applied starting from frame 0" | ||
| ): | ||
| u.trajectory.add_transformations(NoJump()) | ||
| _ = u.trajectory.timeseries() |
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'm a bit confused by the _ = ... lines here and above. Why are they different in each case?
In my hands, I can just delete both of those lines, and the tests still pass, so that seems preferable:
--- a/testsuite/MDAnalysisTests/transformations/test_nojump.py
+++ b/testsuite/MDAnalysisTests/transformations/test_nojump.py
@@ -393,7 +393,6 @@ def test_nojump_fails_when_not_at_frame_0():
ValueError, match="must be applied starting from frame 0"
):
u.trajectory.add_transformations(NoJump())
- _ = u.trajectory[0]
def test_nojump_fails_midtrajectory():
@@ -407,4 +406,3 @@ def test_nojump_fails_midtrajectory():
ValueError, match="must be applied starting from frame 0"
):
u.trajectory.add_transformations(NoJump())
- _ = u.trajectory.timeseries()Then, after making that change, it should be trivial to condense this into a single parametrized test to reduce duplication.
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.
_ = u.trajectory[0] I thought that _transform() was called when you access a frame, so this was to trigger frame access, and _ = u.trajectory.timeseries() - to trigger iteration
So, I will remove it, the variables was indeed not necessary.
| transformed_coordinates = u.trajectory.timeseries()[0] | ||
|
|
||
|
|
||
| def test_nojump_fails_when_not_at_frame_0(): |
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.
You combine these two separate tests into a single parameterized test, passing in the two values -1 and 5 to test both cases rather than duplicating code.
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.
ok, that seems nice
|
I'll squash merge it -- it looks like Brady had to repeat my request for test parametrization, and the changelog entry could be a bit clearer (i.e., this behavior already errored out, it was just the error type and the content of the error message that was improved). I think the changelog entry also has a spurious/extra space in it, but doesn't seem like something we need to block on. |
|
Ok, then. |
Fixes #4915
Changes made in this Pull Request:
nojump.pyunder the_transformfunction that checks if theself.prev is None and ts.frame != 0test_nojump.pythat checks for-1and also midwayLLM / AI generated code disclosure
LLMs or other AI-powered tools (beyond simple IDE use cases) were used in this contribution: no
(not needed, I guess this was simple)
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--5201.org.readthedocs.build/en/5201/