-
Notifications
You must be signed in to change notification settings - Fork 652
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
AttributeError when using MDAnalysis.analysis.hydrogenbonds.hbond_analysis with topology file without bonds information #2396
Comments
PR MDAnalysis/pmda#113 has code that can be used to properly raise an exception. |
Fixed the attribute error (MDAnalysis#2396). Added test cases that check the ids and indices of atoms in a hydrogen bond. Co-authored-by: p-j-smith <paul.smith@kcl.ac.uk>
We also corrected it the same way with @p-j-smith after seeing this problem. I think @p-j-smith is more suitable to be an assignee here! |
I had assigned it to you because PR #2572 seemed to be addressing it ... and your icon popped up first. |
This is indeed fixed in PR #2572 and we've added a test for it too |
Cool, thanks. So we’ll just wait for that PR to be merged. |
Caveats when checking for bond presence: import MDAnalysis as mda
from MDAnalysis.tests.datafiles import GRO, TPR
u = mda.Universe(GRO) # universe *without* bonds
%timeit hasattr(u, 'bonds')
# 758 µs ± 4.33 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
%timeit hasattr(u._topology, 'bonds')
# 216 ns ± 2.88 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
u = mda.Universe(TPR) # universe *with* bonds
%timeit hasattr(u, 'bonds')
# 88.8 ms ± 524 µs per loop (mean ± std. dev. of 7 runs, 10 loops each) <== AAARGH!
%timeit hasattr(u._topology, 'bonds')
# 86.4 ns ± 0.266 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each) You see that in the latter example, |
It is a million times faster to access. See MDAnalysis#2396 (comment)
Expected behavior
When given a universe without bonds attribute, should raise Exception
Actual behavior
And AttributeError was raised:
Code to reproduce the behavior
Show us how to reproduce the failiure. If you can, use trajectory files from the test data.
Currently version of MDAnalysis
0.21.0
3.6.9
The text was updated successfully, but these errors were encountered: