-
Notifications
You must be signed in to change notification settings - Fork 640
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
Pytest style analysis/test_distances.py #1541
Conversation
assert_equal(contacts.shape, self.shape, | ||
"wrong shape (should be {0})".format(self.shape)) | ||
contacts = MDAnalysis.analysis.distances.contact_matrix(self.coord, cutoff=1, returntype="numpy") | ||
assert contacts.shape == self.shape, "wrong shape (should be {0})".format(self.shape) |
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.
This looks like you break the 80 char line limit. Also these tests look like they could be parametrized.
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.
@kain88-de All the 4 methods have different check in the assert_equal
statement. If you want to parametrize, I'll have to send both the values that will be compared. I don't think that's a good idea.
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.
called np.asarray(...)
on the contacts should also work for the sparse case
[1, 0, 1, 1, 1]], dtype=np.bool) | ||
|
||
class TestContactMatrix(object): | ||
coord = np.array([[1, 1, 1], |
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 problem with declaring arrays in the class namespace like this is they can be accidentally modified by a test, and they will remain changed for all other tests (I think?)
del self.expected | ||
|
||
class TestDist(object): | ||
u = MDAnalysis.Universe(GRO) |
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.
Same here, we shouldn't just be loading everything into the class namespace
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.
Should use fixtures more
@richardjgowers Better now? |
@utkbansal the coverage went down with the latest changes |
@kain88-de I don't see how that happened, have restarted the build. |
Fixes #
Changes made in this Pull Request:
PR Checklist