-
Notifications
You must be signed in to change notification settings - Fork 666
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
different atom number error message #2219
Conversation
Not sure why appveyor failed, ignore that. Can you check that there’s a test for a pdb file with varying atoms per frame? Should be in one of the test_pdb.py files |
Hi @richardjgowers , pytest test_pdb.py, it did not show errors related to the varing atoms per 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.
Error message needs to be improved and, as @richardjgowers already mentioned, tests are needed as well.
@@ -393,15 +393,16 @@ def _read_frame(self, frame): | |||
line[24:33], line[33:40], | |||
line[40:47], line[47:54]] | |||
|
|||
# doing the conversion from list to array at the end is faster | |||
self.ts.positions = tmp_buf | |||
|
|||
# check if atom number changed | |||
if pos != self.n_atoms: | |||
raise ValueError("Read an incorrect number of atoms\n" |
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 error message is still somewhat misleading. In fact, the number of atoms read is correct, and reading has nothing to do with the error. Also, the number of atoms read from the trajectory frame reported in the error message seems to be wrong (pos+1
instead of pos
). I'd suggest changing the error to
...
if pos != self.n_atoms:
raise ValueError("Inconsistency in file '{}': The number of atoms "
"({}) in trajectory frame {} differs from the "
"number of atoms ({}) in the corresponding "
"topology.\nTrajectories with varying numbers of "
"atoms are currently not supported."
"".format(self.filename, pos, frame, self.n_atoms)
Codecov Report
@@ Coverage Diff @@
## develop #2219 +/- ##
===========================================
+ Coverage 89.57% 89.58% +<.01%
===========================================
Files 158 158
Lines 19724 19687 -37
Branches 2780 2769 -11
===========================================
- Hits 17668 17636 -32
+ Misses 1460 1457 -3
+ Partials 596 594 -2
Continue to review full report at Codecov.
|
Hi @zemanj . Thanks for your suggestion. I looked through the test_PDB file and not find the test I need. So I try to write one like
However, I do not know how to make the ValueError happen. Also when I try to give PDBReader a n_atoms parameter, it report indexerror, is there a test file that contain different atom number, that I can use to test it. Or maybe I'm totally wrong about this thing. |
Hey @Yibo-Zhang , the problem here is you need to trigger the error with the file you use in the test. The file you're currently using has nothing wrong with it, so you never check the piece of code you've modified. Instead, if you give it a pdb file where the number of atoms changes between frames, you can test that you get the expected behaviour (ie a ValueError with a useful error message). Inside |
Hey @richardjgowers , I added the test for the changed part, and it works. Can you have a quick review. Thanks |
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 to me.
@richardjgowers and @zemanj do you want to have a quick look?
@Yibo-Zhang please also
|
@Yibo-Zhang if you want this to get merged soon please add yourself to AUTHORS and add an entry to CHANGELOG #2219 (comment) @zemanj please check if your comments have been addressed, your approval is missing. Thanks. |
hey @orbeckst I added that two parts, thanks. I'm so happy that I can add my name at authors list. |
Conflicts need to be resolved, otherwise this looks really good! |
Congratulations @Yibo-Zhang , your first PR has been merged, thank you for your contribution. I hope more will follow! |
Update of AUTHORS and CHANGELOG with inferred author contributions. * Removed duplicate mattwthompson in 0.20.0 changelog entry.: mattwthompson was placed twice by accident, this removes this duplication. * Addition of missing authors. An retrospective analysis of the authors found via `git shortlog -s -n --email --branches="develop"` found several commits by authors which were not present in the `AUTHORS.md` file. - Zhenbo Li: commited via PR: Started tests for gnm. #803 and Make Travis run tests on OSX. #771, - Jenna M. Swarthout via PR Update CoC according to suggestions from current CoC committee #4289 and Point to new reporting form link (owned by [email protected]) #4298, - Bradley Dice via PR Fix GSD Windows compatibility #2384 , - David Minh via PR #2668 There seemed to be no indications in the above mentioned PRs that the author did not want to be in the authors file, it looks like it was just forgotten. * Addition of missing entries from the changelog Continued cross referencing of the git shortlog output but also accounting for the changelog identified several individuals that had not been included in the changelog entries for the release they contributed under. They were added to the relevant entry of the changelog based on the merge commit date. Please note that for Tone Bengsten, we a) had no github handle (so they were assigned @tbengtsen), and b) no specific commit. Given we know that this individual was including alongside the encore merge, they were assigned to the 0.16.0 release. * Update CHANGELOG * PR #1218 * PR #1284 and #1408 * PR #4109 * based on git history * PRs #803 and #771 (author addition, changelog addition) * PR #2255 and #2221 * PR #1225 * PR #4289 and #4298 * PR #4031 * PR #4085 * PR #3635 * PR #2356 * PR #2559 * No GH handle - Encore author addition @tbengtsen * PR #4184 * PR #2614 * PR #2219 * PR #2384 * PR #2668 * Add missing entry for Jenna Thanks to @fiona-naughton for helping out with digging into this data :) Co-authored-by: Fiona Naughton <[email protected]> Co-authored-by: Oliver Beckstein <[email protected]>
Fixes #1998
Changes made in this Pull Request:
PR Checklist