-
Notifications
You must be signed in to change notification settings - Fork 666
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
distopia 0.3.0 compatibility changes #4734
Open
hmacdope
wants to merge
35
commits into
MDAnalysis:develop
Choose a base branch
from
hmacdope:distopia_0.3.0_compat
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 23 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
2ee12e5
start of docs
hmacdope 9bf0cf7
improve distopia stup
hmacdope f8d1295
add backend conditionals
hmacdope badc778
fix wrong backend
hmacdope e97317b
shims
hmacdope e0ce653
working except for dihedrals
hmacdope 63162df
move to 0.3.0
hmacdope 0ec2057
bump ci
hmacdope 2392101
bump ci
hmacdope 2cb04d2
Update package/MDAnalysis/lib/distances.py
hmacdope e4b8a10
Merge remote-tracking branch 'upstream/develop' into distopia_0.3.0_c…
hmacdope 517c676
fix versioning
hmacdope 36de301
add version checking
hmacdope b49b028
remove erroneous triclinic note
hmacdope d895d99
remove unnesecary import
hmacdope 5733a74
add explanatory notes
hmacdope 36c010a
change tests in line with discussion
hmacdope 763b493
changelog
hmacdope 10356f7
Apply suggestions from code review
hmacdope 3b0024a
add more tests
hmacdope 9c149ec
improve docs
hmacdope 8cae6f8
improve docs again
hmacdope 50efeb9
hmmm
hmacdope 2c070b7
Merge branch 'develop' into distopia_0.3.0_compat
orbeckst d4b9e9d
add type for calc_bond_distance_ortho()
orbeckst 2621552
just stuff answers back in if we used a buffer
hmacdope 154d389
Merge branch 'distopia_0.3.0_compat' of github.com:hmacdope/mdanalysi…
hmacdope c75dce2
add cram for distance array also
hmacdope 02a3d93
fix changelogs
hmacdope 07f1438
Merge remote-tracking branch 'upstream/develop' into distopia_0.3.0_c…
hmacdope 9101d81
black
hmacdope 447beac
imporve mock test
hmacdope 0a60016
fix typo
hmacdope 730cee9
add debug printing
hmacdope a865a46
Merge branch 'develop' into distopia_0.3.0_compat
orbeckst 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 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 |
---|---|---|
|
@@ -28,57 +28,123 @@ | |
as a selectable backend. | ||
""" | ||
import warnings | ||
from packaging.version import Version | ||
|
||
MIN_DISTOPIA_VERSION = Version("0.3.1") | ||
|
||
# check for distopia | ||
try: | ||
import distopia | ||
except ImportError: | ||
HAS_DISTOPIA = False | ||
distopia_version = Version("0.0.0") | ||
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]) | ||
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 | ||
# check for compatibility: currently needs to be >=0.3.1, | ||
# some versions of `distopia` don't have a version attribute | ||
try: | ||
distopia_version = Version(distopia.__version__) | ||
except AttributeError: | ||
warnings.warn("distopia version cannot be determined, assuming 0.0.0") | ||
distopia_version = Version("0.0.0") | ||
if distopia_version < MIN_DISTOPIA_VERSION: | ||
warnings.warn( | ||
f"distopia version {distopia_version} is too old; " | ||
f"need at least {MIN_DISTOPIA_VERSION}, Your installed version of " | ||
"distopia will NOT be used.", category=RuntimeWarning | ||
) | ||
HAS_DISTOPIA = False | ||
|
||
|
||
from .c_distances import ( | ||
hmacdope marked this conversation as resolved.
Show resolved
Hide resolved
|
||
calc_bond_distance_triclinic as _calc_bond_distance_triclinic_serial, | ||
) | ||
import numpy as np | ||
|
||
|
||
def calc_bond_distance_ortho( | ||
coords1, coords2: np.ndarray, box: np.ndarray, results: np.ndarray | ||
orbeckst marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) -> None: | ||
distopia.calc_bonds_ortho_float( | ||
distopia.calc_bonds_ortho( | ||
hmacdope marked this conversation as resolved.
Show resolved
Hide resolved
|
||
coords1, coords2, box[:3], results=results | ||
) | ||
# upcast is currently required, change for 3.0, see #3927 | ||
|
||
|
||
|
||
def calc_bond_distance( | ||
coords1: np.ndarray, coords2: np.ndarray, results: np.ndarray | ||
) -> None: | ||
distopia.calc_bonds_no_box_float( | ||
distopia.calc_bonds_no_box( | ||
coords1, coords2, results=results | ||
) | ||
# upcast is currently required, change for 3.0, see #3927 | ||
|
||
|
||
def calc_bond_distance_triclinic( | ||
coords1: np.ndarray, coords2: np.ndarray, box: np.ndarray, results: np.ndarray | ||
) -> None: | ||
# redirect to serial backend | ||
warnings.warn( | ||
"distopia does not support triclinic boxes, using serial backend instead." | ||
) | ||
_calc_bond_distance_triclinic_serial(coords1, coords2, box, results) | ||
distopia.calc_bonds_triclinic(coords1, coords2, box, results=results) | ||
|
||
|
||
def calc_angle( | ||
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. |
||
coords1: np.ndarray, coords2: np.ndarray, coords3: np.ndarray, results: np.ndarray | ||
) -> None: | ||
distopia.calc_angles_no_box(coords1, coords2, coords3, results=results) | ||
|
||
|
||
def calc_angle_ortho( | ||
coords1: np.ndarray, coords2: np.ndarray, coords3: np.ndarray, box: np.ndarray, results: np.ndarray | ||
) -> None: | ||
distopia.calc_angles_ortho(coords1, coords2, coords3, box[:3], results=results) | ||
|
||
|
||
def calc_angle_triclinic( | ||
coords1: np.ndarray, coords2: np.ndarray, coords3: np.ndarray, box: np.ndarray, results: np.ndarray | ||
) -> None: | ||
|
||
distopia.calc_angles_triclinic(coords1, coords2, coords3, box, results=results) | ||
|
||
|
||
def calc_dihedral( | ||
coords1: np.ndarray, coords2: np.ndarray, coords3: np.ndarray, coords4: np.ndarray, results: np.ndarray | ||
) -> None: | ||
distopia.calc_dihedrals_no_box(coords1, coords2, coords3, coords4, results=results) | ||
|
||
def calc_dihedral_ortho( | ||
coords1: np.ndarray, coords2: np.ndarray, coords3: np.ndarray, coords4: np.ndarray, box: np.ndarray, results: np.ndarray | ||
) -> None: | ||
distopia.calc_dihedrals_ortho(coords1, coords2, coords3, coords4, box[:3], results=results) | ||
|
||
def calc_dihedral_triclinic( | ||
coords1: np.ndarray, coords2: np.ndarray, coords3: np.ndarray, coords4: np.ndarray, box: np.ndarray, results: np.ndarray | ||
) -> None: | ||
distopia.calc_dihedrals_triclinic(coords1, coords2, coords3, coords4, box, results=results) | ||
|
||
def calc_distance_array( | ||
coords1: np.ndarray, coords2: np.ndarray, results: np.ndarray | ||
) -> None: | ||
distopia.calc_distance_array_no_box(coords1, coords2, results=results) | ||
|
||
|
||
def calc_distance_array_ortho( | ||
coords1: np.ndarray, coords2: np.ndarray, box: np.ndarray, results: np.ndarray | ||
) -> None: | ||
distopia.calc_distance_array_ortho(coords1, coords2, box[:3], results=results) | ||
|
||
def calc_distance_array_triclinic( | ||
hmacdope marked this conversation as resolved.
Show resolved
Hide resolved
|
||
coords1: np.ndarray, coords2: np.ndarray, box: np.ndarray, results: np.ndarray | ||
) -> None: | ||
distopia.calc_distance_array_triclinic(coords1, coords2, box, results=results) | ||
hmacdope marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def calc_self_distance_array( | ||
hmacdope marked this conversation as resolved.
Show resolved
Hide resolved
|
||
coords: np.ndarray, results: np.ndarray | ||
) -> None: | ||
distopia.calc_self_distance_array_no_box(coords, results=results) | ||
hmacdope marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def calc_self_distance_array_ortho( | ||
hmacdope marked this conversation as resolved.
Show resolved
Hide resolved
|
||
coords: np.ndarray, box: np.ndarray, results: np.ndarray | ||
) -> None: | ||
distopia.calc_self_distance_array_ortho(coords, box[:3], results=results) | ||
|
||
def calc_self_distance_array_triclinic( | ||
hmacdope marked this conversation as resolved.
Show resolved
Hide resolved
|
||
coords: np.ndarray, box: np.ndarray, results: np.ndarray | ||
) -> None: | ||
distopia.calc_self_distance_array_triclinic(coords, box, results=results) | ||
|
Oops, something went wrong.
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.
Are these versions known? I.e. if we know that this only affects a certain set of releases and they are all <0.3.1, then can we skip the warning altogther and just assume that this only happens in old versions we don't care about?
(intent: I'm trying to completly bypass the follow-up "there are no tests for line 50" with a blunt solution)