-
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
DCD XDR pickle tests #2911
DCD XDR pickle tests #2911
Changes from 5 commits
8deaf09
9c02300
b7eaad8
e3f7c6d
08fa285
afd2052
5e9d11b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -306,8 +306,14 @@ cdef class _XDRFile: | |
|
||
# where was I | ||
current_frame = state[1] | ||
self.seek(current_frame - 1) | ||
self.current_frame = current_frame | ||
if current_frame == self.offsets.size: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switch the decision in the if current_frame < self.offsets.size:
...
elif current_frame == self.offsets.size:
...
else:
#pragma: no cov
raise RuntimeError("Invalid frame number {} > {} -- this should not happen.".format(current_frame, self.offsets.size) and add defensive code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add comment under which circumstances we have to do funny things – namely when we need to serialize at the end of the trajectory. |
||
# cannot seek to self.offsets.size (like in DCD file) | ||
# because here seeking depends on the offsets list size. | ||
# Instead, we seek to one frame ahead and read the next frame. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean "previous frame" instead of "frame ahead"? |
||
self.seek(current_frame - 1) | ||
_ = self.read() | ||
else: | ||
self.seek(current_frame) | ||
|
||
def seek(self, frame): | ||
"""Seek to Frame. | ||
|
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.
Is this supposed to allow to seek to the end of the file? If so, add a comment, because under normal circumstances I expect a 0-based index for a sequence to fail when it hits
len(sequence)
.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.
If it is possible to seek to the end of the file (after the last coordinate frame) with
then state it in the doc string. This is a fairly odd thing to allow so it should be documented.