-
Notifications
You must be signed in to change notification settings - Fork 634
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
A Universe now holds onto its initialization kwargs. #813
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a72a480
A Universe now holds onto its initialization kwargs.
dotsdl 3a08994
Added tests for Universe keeping a copy of its init kwargs.
dotsdl 2911fb6
Test equality of full kwargs dict
dotsdl 7fa936a
Exposed Universe kwargs with read-only property
dotsdl c708c6a
Updated changelog with Universe kwargs exposure
dotsdl 777412d
guess_bounds -> guess_bonds
dotsdl 0351aad
Made test for universe kwargs staticmethod since we don't use self
dotsdl 68307a2
Removed `self` from staticmethod test.
dotsdl File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1724,7 +1724,20 @@ def test_set_dimensions(self): | |
u.dimensions = np.array([10, 11, 12, 90, 90, 90]) | ||
assert_allclose(u.dimensions, box) | ||
|
||
@staticmethod | ||
def test_universe_kwargs(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you also need to remove the self variable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Sorry! |
||
u = MDAnalysis.Universe(PSF, PDB_small, fake_kwarg=True) | ||
assert_equal(len(u.atoms), 3341, "Loading universe failed somehow") | ||
|
||
assert_(u.kwargs['fake_kwarg'] is True) | ||
|
||
# initialize new universe from pieces of existing one | ||
u2 = MDAnalysis.Universe(u.filename, u.trajectory.filename, | ||
**u.kwargs) | ||
|
||
assert_(u2.kwargs['fake_kwarg'] is True) | ||
assert_equal(u.kwargs, u2.kwargs) | ||
|
||
class TestPBCFlag(TestCase): | ||
@dec.skipif(parser_not_found('TRZ'), | ||
'TRZ parser not available. Are you using python 3?') | ||
|
@@ -2121,11 +2134,13 @@ def _check_universe(self, u): | |
assert_equal(len(u.atoms[3].bonds), 2) | ||
assert_equal(len(u.atoms[4].bonds), 1) | ||
assert_equal(len(u.atoms[5].bonds), 1) | ||
assert_('guess_bonds' in u.kwargs) | ||
|
||
def test_universe_guess_bonds(self): | ||
"""Test that making a Universe with guess_bonds works""" | ||
u = MDAnalysis.Universe(two_water_gro, guess_bonds=True) | ||
self._check_universe(u) | ||
assert_(u.kwargs['guess_bonds'] is True) | ||
|
||
def test_universe_guess_bonds_no_vdwradii(self): | ||
"""Make a Universe that has atoms with unknown vdwradii.""" | ||
|
@@ -2136,13 +2151,16 @@ def test_universe_guess_bonds_with_vdwradii(self): | |
u = MDAnalysis.Universe(two_water_gro_nonames, guess_bonds=True, | ||
vdwradii=self.vdw) | ||
self._check_universe(u) | ||
assert_(u.kwargs['guess_bonds'] is True) | ||
assert_equal(self.vdw, u.kwargs['vdwradii']) | ||
|
||
def test_universe_guess_bonds_off(self): | ||
u = MDAnalysis.Universe(two_water_gro_nonames, guess_bonds=False) | ||
|
||
assert_equal(len(u.bonds), 0) | ||
assert_equal(len(u.angles), 0) | ||
assert_equal(len(u.dihedrals), 0) | ||
assert_(u.kwargs['guess_bonds'] is False) | ||
|
||
def _check_atomgroup(self, ag, u): | ||
"""Verify that the AtomGroup made bonds correctly, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
QC has a good point here making this a
staticmethod
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.
Because we don't use
self
anywhere inside? Many of the other methods don't useself
anywhere inside either.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.
I like QC's rationale for making it
@staticmethod
:"This will improve performance and make it clear to users of your code that the function does not use any attributes of the class."
We should do it when we can.
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.
Alright, done.