-
Notifications
You must be signed in to change notification settings - Fork 667
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
FrameIteratorIndices doesn't rewind whilst FrameIteratorSliced does #3416
Comments
Looking into it more, looks like a possibly intention decision by @jbarnoud ? |
I looked through PR #1934 and although there are some interesting comments like #1934 (comment) (why FrameIterators are like mdanalysis/package/MDAnalysis/coordinates/base.py Lines 992 to 995 in 3985021
FrameIteratorIndices does not mdanalysis/package/MDAnalysis/coordinates/base.py Lines 1112 to 1115 in 3985021
Given that I can't think of a use case where this should be handled differently, especially as it breaks user expectations (and is not documented either). |
From what I can see, there is no reason for the inconsistency. All the frame iterators should rewind. On 8 Sep 2021 02:41, Oliver Beckstein ***@***.***> wrote:
I looked through PR #1934 and although there are some interesting comments like #1934 (comment) (why FrameIterators are like range() and not really iterators) I couldn't see a real reason why FrameIteratorSliced rewinds in __iter__ https://github.com/MDAnalysis/mdanalysis/blob/39850215eae5a3e2c9d28a24dbc670646e305f79/package/MDAnalysis/coordinates/base.py#L992-L995 while FrameIteratorIndices does not https://github.com/MDAnalysis/mdanalysis/blob/39850215eae5a3e2c9d28a24dbc670646e305f79/package/MDAnalysis/coordinates/base.py#L1112-L1115
Given that FrameIteratorAll just defers to the reader's behavior (which rewinds) it looks to me that FrameIteratorIndices should do the same.
I can't think of a use case where this should be handled differently, especially as it breaks user expectations (and is not documented either).
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications on the go with GitHub Mobile for iOS or Android.
|
Looks like the consensus here is to just add the rewind. Do we need to warn or can we treat this as a bug and fix in 2.1.0? |
I think we can treat it as a bug fix.
|
As elsewhere #3423 (comment) I'd like to label this issue a defect because the behavior is not documented and wasn't intended as such. A fix would fix the API to be consistent with the rest of the readers. |
Hello! My current understanding is: Questions: I'm also wondering logistically if/how bugs are handled differently from defects from a programming and documentation perspective? (per #3416 (comment)) Thank you for your help! |
Yes.
Good question. I'd say yes, for consistency, because that's what FrameIteratorSliced is already doing. (The alternative would be to rewind to the first frame index but that seems less consistent with what we have at the moment.)
I use bugs and defects synonymously. What difference do you perceive? In this specific case the question was if the change will be an API change or a bug fix (= defect fix). Because we use semantic versioning this has wide-ranging implication. Under SemVer, we can only make backwards-incompatible API changes when we increase the major release number (e.g., the next one would be 3.0.0). Bug-fixes can go in a patch release, e.g., 2.1.1 or in the next minor release 2.2.0. The consensus seemed to be that this is not an intentional API change but we are fixing undocumented behavior. Thus, a PR can actually be merged right away and does not have to wait for 3.0.0. |
- Previously iterating through FrameIteratorIndices did not rewind back to 0 and stayed on the last iterated frame - FrameIteratorIndices now rewinds back to 0 and is consistent with FrameIteratorSliced and FrameIteratorAll
- Previously iterating through FrameIteratorIndices did not rewind back to 0 and stayed on the last iterated frame - FrameIteratorIndices now rewinds back to 0 and is consistent with FrameIteratorSliced and FrameIteratorAll
* Fix FrameIteratorIndices doesn't rewind (Issue #3416) - Previously iterating through FrameIteratorIndices did not rewind back to 0 and stayed on the last iterated frame. - FrameIteratorIndices now rewinds back to 0 and is consistent with FrameIteratorSliced and FrameIteratorAll. Co-authored-by: IAlibay <[email protected]>
Related to #3415
Expected behavior
See #3415 (comment)
Iterating through FrameIteratorSliced should leave u.trajectory at the same point as if I iterated through FrameIteratorIndices.
Actual behavior
The former rewinds whilst the latter doesn't.
I might be missing a pythonic reason (which I'd be happy to accept), just bringing this up because of discussions on #3415
Code to reproduce the behavior
Ouput: < Timestep 2 with unit cell dimensions [79.98359 79.98359 79.98358 60. 60. 90. ] >
Whilst:
Ouput: < Timestep 0 with unit cell dimensions [80.017006 80.017006 80.017006 60. 60. 90. ] >
Current version of MDAnalysis
python -c "import MDAnalysis as mda; print(mda.__version__)"
) developpython -V
)? 3.9The text was updated successfully, but these errors were encountered: