-
Notifications
You must be signed in to change notification settings - Fork 672
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
pin distopia<0.3.0 #4740
pin distopia<0.3.0 #4740
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
This module is a stub to provide distopia distance functions to `distances.py` | ||
as a selectable backend. | ||
""" | ||
import warnings | ||
|
||
# check for distopia | ||
try: | ||
|
@@ -36,10 +37,22 @@ | |
else: | ||
HAS_DISTOPIA = True | ||
|
||
# check for compatibility: currently needs to be >=0.2.0,<0.3.0 (issue | ||
# #4740) No distopia.__version__ available so we have to do some probing. | ||
needed_funcs = ['calc_bonds_no_box_float', 'calc_bonds_ortho_float'] | ||
has_distopia_020 = all([hasattr(distopia, func) for func in needed_funcs]) | ||
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. There's no @hmacdope is there a better way to get the version of the installed distopia package? 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. ^ See comment above, I will make a patch release, I accidentally removed |
||
if not has_distopia_020: | ||
warnings.warn("Install 'distopia>=0.2.0,<0.3.0' to be used with this " | ||
"release of MDAnalysis. Your installed version of " | ||
"distopia >=0.3.0 will NOT be used.", | ||
category=RuntimeWarning) | ||
del distopia | ||
HAS_DISTOPIA = False | ||
|
||
|
||
from .c_distances import ( | ||
calc_bond_distance_triclinic as _calc_bond_distance_triclinic_serial, | ||
) | ||
import warnings | ||
import numpy as np | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ | |
# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations. | ||
# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787 | ||
# | ||
import sys | ||
from unittest.mock import Mock, patch | ||
import pytest | ||
import numpy as np | ||
from numpy.testing import assert_equal, assert_almost_equal, assert_allclose | ||
|
@@ -788,9 +790,10 @@ def test_pbc_wrong_wassenaar_distance(self, backend): | |
# expected. | ||
assert np.linalg.norm(point_a - point_b) != dist[0, 0] | ||
|
||
@pytest.mark.parametrize("box", | ||
|
||
@pytest.mark.parametrize("box", | ||
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. pep8 fix |
||
[ | ||
None, | ||
None, | ||
np.array([10., 15., 20., 90., 90., 90.]), # otrho | ||
np.array([10., 15., 20., 70.53571, 109.48542, 70.518196]), # TRIC | ||
] | ||
|
@@ -835,6 +838,39 @@ def distopia_conditional_backend(): | |
return ["serial", "openmp"] | ||
|
||
|
||
def test_HAS_DISTOPIA_incompatible_distopia(): | ||
# warn if distopia is the wrong version and set HAS_DISTOPIA to False | ||
sys.modules.pop("distopia", None) | ||
sys.modules.pop("MDAnalysis.lib._distopia", None) | ||
|
||
# fail any Attribute access for calc_bonds_ortho_float, | ||
# calc_bonds_no_box_float but pretend to have the distopia | ||
# 0.3.0 functions (from | ||
# https://github.com/MDAnalysis/distopia/blob/main/distopia/__init__.py | ||
# __all__): | ||
mock_distopia_030 = Mock(spec=[ | ||
'calc_bonds_ortho', | ||
'calc_bonds_no_box', | ||
'calc_bonds_triclinic', | ||
'calc_angles_no_box', | ||
'calc_angles_ortho', | ||
'calc_angles_triclinic', | ||
'calc_dihedrals_no_box', | ||
'calc_dihedrals_ortho', | ||
'calc_dihedrals_triclinic', | ||
'calc_distance_array_no_box', | ||
'calc_distance_array_ortho', | ||
'calc_distance_array_triclinic', | ||
'calc_self_distance_array_no_box', | ||
'calc_self_distance_array_ortho', | ||
'calc_self_distance_array_triclinic', | ||
]) | ||
with patch.dict("sys.modules", {"distopia": mock_distopia_030}): | ||
with pytest.warns(RuntimeWarning, | ||
match="Install 'distopia>=0.2.0,<0.3.0' to"): | ||
import MDAnalysis.lib._distopia | ||
assert not MDAnalysis.lib._distopia.HAS_DISTOPIA | ||
|
||
class TestCythonFunctions(object): | ||
# Unit tests for calc_bonds calc_angles and calc_dihedrals in lib.distances | ||
# Tests both numerical results as well as input types as Cython will silently | ||
|
@@ -1597,7 +1633,7 @@ def test_empty_input_self_capped_distance(self, empty_coord, min_cut, box, | |
assert_equal(res[1], np.empty((0,), dtype=np.float64)) | ||
else: | ||
assert_equal(res, np.empty((0, 2), dtype=np.int64)) | ||
|
||
@pytest.mark.parametrize('box', boxes[:2]) | ||
@pytest.mark.parametrize('backend', ['serial', 'openmp']) | ||
def test_empty_input_transform_RtoS(self, empty_coord, box, backend): | ||
|
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.
Not sure if we would normally make a CHANGELOG entry but in this case I would recommend to do so because there is not other part in the user-visible code base that knows about this requirement. If someone installs distopia by themselves, they will see failures.
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.
Now they will (hopefully) a warning