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

distopia 0.3.0 compatibility changes #4734

Open
wants to merge 35 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2ee12e5
start of docs
hmacdope Oct 15, 2024
9bf0cf7
improve distopia stup
hmacdope Oct 15, 2024
f8d1295
add backend conditionals
hmacdope Oct 15, 2024
badc778
fix wrong backend
hmacdope Oct 15, 2024
e97317b
shims
hmacdope Oct 15, 2024
e0ce653
working except for dihedrals
hmacdope Oct 15, 2024
63162df
move to 0.3.0
hmacdope Oct 16, 2024
0ec2057
bump ci
hmacdope Oct 16, 2024
2392101
bump ci
hmacdope Oct 17, 2024
2cb04d2
Update package/MDAnalysis/lib/distances.py
hmacdope Oct 21, 2024
e4b8a10
Merge remote-tracking branch 'upstream/develop' into distopia_0.3.0_c…
hmacdope Oct 21, 2024
517c676
fix versioning
hmacdope Oct 21, 2024
36de301
add version checking
hmacdope Oct 21, 2024
b49b028
remove erroneous triclinic note
hmacdope Oct 21, 2024
d895d99
remove unnesecary import
hmacdope Oct 21, 2024
5733a74
add explanatory notes
hmacdope Oct 21, 2024
36c010a
change tests in line with discussion
hmacdope Oct 21, 2024
763b493
changelog
hmacdope Oct 21, 2024
10356f7
Apply suggestions from code review
hmacdope Oct 23, 2024
3b0024a
add more tests
hmacdope Oct 23, 2024
9c149ec
improve docs
hmacdope Oct 23, 2024
8cae6f8
improve docs again
hmacdope Oct 23, 2024
50efeb9
hmmm
hmacdope Oct 24, 2024
2c070b7
Merge branch 'develop' into distopia_0.3.0_compat
orbeckst Dec 10, 2024
d4b9e9d
add type for calc_bond_distance_ortho()
orbeckst Dec 10, 2024
2621552
just stuff answers back in if we used a buffer
hmacdope Dec 31, 2024
154d389
Merge branch 'distopia_0.3.0_compat' of github.com:hmacdope/mdanalysi…
hmacdope Dec 31, 2024
c75dce2
add cram for distance array also
hmacdope Dec 31, 2024
02a3d93
fix changelogs
hmacdope Dec 31, 2024
07f1438
Merge remote-tracking branch 'upstream/develop' into distopia_0.3.0_c…
hmacdope Jan 2, 2025
9101d81
black
hmacdope Jan 2, 2025
447beac
imporve mock test
hmacdope Jan 2, 2025
0a60016
fix typo
hmacdope Jan 2, 2025
730cee9
add debug printing
hmacdope Jan 2, 2025
a865a46
Merge branch 'develop' into distopia_0.3.0_compat
orbeckst Jan 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/setup-deps/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ inputs:
dask:
default: 'dask'
distopia:
default: 'distopia>=0.2.0,<0.3.0'
default: 'distopia>=0.3.1'
h5py:
default: 'h5py>=2.10'
hole2:
Expand Down
4 changes: 3 additions & 1 deletion package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The rules for this file:
ljwoods2, aditya292002, pstaerk, PicoCentauri, BFedder,
tyler.je.reddy, SampurnaM, leonwehrhan, kainszs, orionarcher,
yuxuanzhuang, PythonFZ, laksh-krishna-sharma, orbeckst, MattTDavies,
talagayev, aya9aladdin
talagayev, aya9aladdin, hmacdope

* 2.8.0

Expand Down Expand Up @@ -59,6 +59,8 @@ Fixes
* Fix groups.py doctests using sphinx directives (Issue #3925, PR #4374)

Enhancements
* Improve distopia backend support in line with new functionality available
in distopia >= 0.3.1 (PR #4734)
* Removed type and mass guessing from all topology parsers (PR #3753)
* Added guess_TopologyAttrs() API to the Universe to handle attribute
guessing (PR #3753)
Expand Down
110 changes: 88 additions & 22 deletions package/MDAnalysis/lib/_distopia.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

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)

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")

Check warning on line 50 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L46-L50

Added lines #L46 - L50 were not covered by tests
if distopia_version < MIN_DISTOPIA_VERSION:
warnings.warn(

Check warning on line 52 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L52

Added line #L52 was not covered by tests
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(

Check warning on line 66 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L66

Added line #L66 was not covered by tests
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(

Check warning on line 75 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L75

Added line #L75 was not covered by tests
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)

Check warning on line 83 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L83

Added line #L83 was not covered by tests


def calc_angle(
Copy link
Member

Choose a reason for hiding this comment

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

Has @RMeli lint lib? If so, could you run black on this file @hmacdope ?

coords1: np.ndarray, coords2: np.ndarray, coords3: np.ndarray, results: np.ndarray
) -> None:
distopia.calc_angles_no_box(coords1, coords2, coords3, results=results)

Check warning on line 89 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L89

Added line #L89 was not covered by tests


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)

Check warning on line 95 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L95

Added line #L95 was not covered by tests


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)

Check warning on line 102 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L102

Added line #L102 was not covered by tests


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)

Check warning on line 108 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L108

Added line #L108 was not covered by tests

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)

Check warning on line 113 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L113

Added line #L113 was not covered by tests

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)

Check warning on line 118 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L118

Added line #L118 was not covered by tests

def calc_distance_array(
coords1: np.ndarray, coords2: np.ndarray, results: np.ndarray
) -> None:
distopia.calc_distance_array_no_box(coords1, coords2, results=results)

Check warning on line 123 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L123

Added line #L123 was not covered by tests


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)

Check warning on line 129 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L129

Added line #L129 was not covered by tests

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)

Check warning on line 134 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L134

Added line #L134 was not covered by tests
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)

Check warning on line 139 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L139

Added line #L139 was not covered by tests
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)

Check warning on line 144 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L144

Added line #L144 was not covered by tests

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)

Check warning on line 149 in package/MDAnalysis/lib/_distopia.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/lib/_distopia.py#L149

Added line #L149 was not covered by tests

Loading
Loading