Skip to content
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

Merged
merged 2 commits into from Jul 26, 2017

Conversation

utkbansal
Copy link
Member

Fixes #

Changes made in this Pull Request:

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

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
Copy link
Member

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
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parametrize

Copy link
Member Author

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?

Copy link
Member

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
Copy link
Member

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):
Copy link
Member

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

Copy link
Member Author

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.

@kain88-de kain88-de merged commit ed3018a into MDAnalysis:develop Jul 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants