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

Pytest Style analysis/test_diffusionmap.py #1540

Merged
merged 3 commits into from
Jul 29, 2017

Conversation

utkbansal
Copy link
Member

Fixes #

Changes made in this Pull Request:

PR Checklist

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



from MDAnalysisTests.datafiles import PDB, XTC
class TestDiffusionmap(object):
Copy link
Member

Choose a reason for hiding this comment

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

No class needed this is a single file

@staticmethod
@pytest.fixture()
def eigvals(dmap):
return dmap.eigenvalues
Copy link
Member

Choose a reason for hiding this comment

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

Please don't use a fixture for this

Copy link
Member Author

Choose a reason for hiding this comment

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

What should I do with it then? Since there is no class, I can't attach it with self in some other fixture. Should I directly use the values from the dmap fixture?

Copy link
Member

Choose a reason for hiding this comment

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

just use the dmap fixture in functions that want this 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.

Done.

dist.run()
dmap = diffusionmap.DiffusionMap(dist)
dmap.run()
assert_array_almost_equal(dmap.eigenvalues, [1, 1, 1, 1], 4)
Copy link
Member

Choose a reason for hiding this comment

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

You are recalculating the dmap fixture here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don' think so. The value of dist is different here. It has weights=weights_atoms, step=3 which isn't in the dist fixture that is used by the dmap fixture.

@utkbansal utkbansal changed the title [WIP]Pytest Style analysis/test_diffusionmap.py Pytest Style analysis/test_diffusionmap.py Jul 25, 2017
weights_atoms = np.ones(len(backbone.atoms))
dist = diffusionmap.DistanceMatrix(u, select='backbone', weights=weights_atoms, step=3)
dist.run()
dmap = diffusionmap.DiffusionMap(dist)
Copy link
Member

Choose a reason for hiding this comment

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

isn't this the dmap fixture?

Copy link
Member

Choose a reason for hiding this comment

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

Ok it's slightly different



@pytest.fixture()
def dmap(dist):
Copy link
Member

Choose a reason for hiding this comment

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

This can be a module wide fixture

@utkbansal
Copy link
Member Author

@kain88-de Better now?

@kain88-de kain88-de merged commit fda6e36 into MDAnalysis:develop Jul 29, 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

3 participants