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

Projects
None yet
2 participants
@utkbansal
Member

utkbansal commented Jul 23, 2017

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

This comment has been minimized.

@kain88-de

kain88-de Jul 24, 2017

Member

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

This comment has been minimized.

@kain88-de

kain88-de Jul 24, 2017

Member

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)

This comment has been minimized.

@kain88-de

kain88-de Jul 24, 2017

Member

Parametrize

This comment has been minimized.

@utkbansal

utkbansal Jul 25, 2017

Member

@kain88-de Should I break this into two functions? One with assert and another with assert_almost_equal which would be parametrized?

This comment has been minimized.

@kain88-de

kain88-de Jul 25, 2017

Member

they can all use assert_almost_equal

@staticmethod
@pytest.fixture()
def trajectory(universe):
return universe.trajectory

This comment has been minimized.

@kain88-de

kain88-de Jul 24, 2017

Member

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):

This comment has been minimized.

@kain88-de

kain88-de Jul 24, 2017

Member

This should rather be a fixture

This comment has been minimized.

@utkbansal

utkbansal Jul 25, 2017

Member

Not sure how I'd pass it **kwargs then.

@kain88-de kain88-de merged commit ed3018a into MDAnalysis:develop Jul 26, 2017

3 checks passed

QuantifiedCode 2 minor issues introduced.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 90.426%
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment