-
Notifications
You must be signed in to change notification settings - Fork 16
Migrate LomapAtomMapper testing to the gufe mixin #157
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5f8c551
Migrate LomapAtomMapper testing to the gufe mixin
IAlibay 5e81f1d
some fixes
IAlibay af73459
Merge branch 'main' into tokenizable_mixin_mapper
IAlibay 140457a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b503564
Update test_lomapatommapper.py
IAlibay a9562f3
update to non-standard default for shift
IAlibay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -4,9 +4,12 @@ | |
|
|
||
| try: | ||
| import gufe | ||
| from gufe.tests.test_tokenization import GufeTokenizableTestsMixin | ||
|
|
||
| HAS_GUFE = True | ||
| except ImportError: | ||
| # Fake assign to object to avoid issues | ||
| GufeTokenizableTestsMixin = object | ||
| HAS_GUFE = False | ||
|
|
||
|
|
||
|
|
@@ -18,43 +21,46 @@ def test_lomap_atommaper_no_gufe_error(): | |
|
|
||
|
|
||
| @pytest.mark.skipif(not HAS_GUFE, reason="requires gufe installed") | ||
| def test_to_dict_roundtrip(): | ||
| ref_vals = { | ||
| "time": 19, | ||
| "threed": False, | ||
| "max3d": 999.0, | ||
| "element_change": False, | ||
| "seed": "CC", | ||
| "shift": False, | ||
| } | ||
|
|
||
| m = LomapAtomMapper(**ref_vals) | ||
|
|
||
| d = m.to_dict() | ||
|
|
||
| m2 = LomapAtomMapper.from_dict(d) | ||
|
|
||
| assert m2 | ||
| assert m2.time == ref_vals["time"] | ||
| assert m2.threed == ref_vals["threed"] | ||
| assert m2.max3d == ref_vals["max3d"] | ||
| assert m2.element_change == ref_vals["element_change"] | ||
| assert m2.seed == ref_vals["seed"] | ||
| assert m2.shift == ref_vals["shift"] | ||
|
|
||
|
|
||
| @pytest.mark.skipif(not HAS_GUFE, reason="requires gufe installed") | ||
| def test_repr(): | ||
| m = LomapAtomMapper() | ||
|
|
||
| assert repr(m) == ( | ||
| class TestLomapAtomMapper(GufeTokenizableTestsMixin): | ||
| cls = LomapAtomMapper | ||
| key = None | ||
| repr = ( | ||
| "<LomapAtomMapper (time=20, threed=True, max3d=1.0, " | ||
| "element_change=True, seed='None', shift=False)>" | ||
| ) | ||
|
|
||
| m = LomapAtomMapper(time=15, seed="c1ccccc1") | ||
|
|
||
| assert repr(m) == ( | ||
| "<LomapAtomMapper (time=15, threed=True, max3d=1.0, " | ||
| "element_change=True, seed='c1ccccc1', shift=False)>" | ||
| ) | ||
| @pytest.fixture | ||
| def instance(self): | ||
| return LomapAtomMapper() | ||
|
|
||
| def test_to_dict_roundtrip_different(self): | ||
| ref_vals = { | ||
| "time": 19, | ||
| "threed": False, | ||
| "max3d": 999.0, | ||
| "element_change": False, | ||
| "seed": "CC", | ||
| "shift": False, | ||
| } | ||
|
|
||
| m = LomapAtomMapper(**ref_vals) | ||
|
|
||
| d = m.to_dict() | ||
|
|
||
| m2 = LomapAtomMapper.from_dict(d) | ||
|
|
||
| assert m2 | ||
|
Contributor
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. Would an isinstance check be better than just the assert?
Member
Author
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. |
||
| assert m2.time == ref_vals["time"] | ||
| assert m2.threed == ref_vals["threed"] | ||
| assert m2.max3d == ref_vals["max3d"] | ||
| assert m2.element_change == ref_vals["element_change"] | ||
| assert m2.seed == ref_vals["seed"] | ||
| assert m2.shift == ref_vals["shift"] | ||
|
|
||
| def test_repr_different(self): | ||
| m = LomapAtomMapper(time=15, seed="c1ccccc1") | ||
|
|
||
| assert repr(m) == ( | ||
| "<LomapAtomMapper (time=15, threed=True, max3d=1.0, " | ||
| "element_change=True, seed='c1ccccc1', shift=False)>" | ||
| ) | ||
Oops, something went wrong.
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.
Since we change the default to "False", should this now be testing "True"?
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.
In this case it's better if it's not the defaults - the roundtrip on the default settings is already taken care of in the underlying mixin. Here I'm just keeping the "old" test, hence the naming containing "different".
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 think I'm probably just missing something, but I was thinking that if we want to test the non defaults here, then it should be "True"?