Skip to content

[WIP]Pytest Style analysis/test_contacts.py - #1545

Merged
kain88-de merged 2 commits into
MDAnalysis:developfrom
utkbansal:analysis-contacts
Jul 26, 2017
Merged

[WIP]Pytest Style analysis/test_contacts.py#1545
kain88-de merged 2 commits into
MDAnalysis:developfrom
utkbansal:analysis-contacts

Conversation

@utkbansal

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

Choose a reason for hiding this comment

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

Parametrize

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants