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
[WIP]Pytest Style analysis/test_contacts.py #1545
Conversation
assert contacts.hard_cut_q([2], 1) == 0 | ||
assert contacts.hard_cut_q([2, 0.5], 1) == 0.5 | ||
assert contacts.hard_cut_q([2, 3], [3, 4]) == 1 | ||
assert contacts.hard_cut_q([4, 5], [3, 4]) == 0 |
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.
Parametrize
assert_equal(contacts.radius_cut_q([2], None, 1), 0) | ||
assert_equal(contacts.radius_cut_q([2, 0.5], None, 1), 0.5) | ||
assert contacts.radius_cut_q([1], None, 2) == 1 | ||
assert contacts.radius_cut_q([2], None, 1) == 0 |
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.
Parametrize
|
||
from MDAnalysisTests import tempdir | ||
|
||
|
||
def test_soft_cut_q(): | ||
# just check some of the extremal points | ||
assert_equal(contacts.soft_cut_q([0], [0]), .5) | ||
assert contacts.soft_cut_q([0], [0]) == .5 | ||
assert_almost_equal(contacts.soft_cut_q([100], [0]), 0) | ||
assert_almost_equal(contacts.soft_cut_q([-100], [0]), 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.
Parametrize
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 Should I break this into two functions? One with assert
and another with assert_almost_equal
which would 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.
they can all use assert_almost_equal
@staticmethod | ||
@pytest.fixture() | ||
def trajectory(universe): | ||
return universe.trajectory |
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.
No fixture needed
def _run_Contacts(self, **kwargs): | ||
acidic = self.universe.select_atoms(self.sel_acidic) | ||
basic = self.universe.select_atoms(self.sel_basic) | ||
def _run_Contacts(self, universe, **kwargs): |
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 should rather be a fixture
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.
Not sure how I'd pass it **kwargs
then.
Fixes #
Changes made in this Pull Request:
PR Checklist