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

Add distopia! #3914

Merged
merged 50 commits into from
Feb 15, 2023
Merged
Changes from 4 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
28bf2f9
add starrt of calc_bonds
Nov 4, 2022
280126e
refactor to use distopia inplace API
hmacdope Nov 9, 2022
8a571d4
add in upcast
hmacdope Nov 10, 2022
d6c9220
actually return the distances
hmacdope Nov 10, 2022
dae07fa
distopia to ci
hmacdope Nov 12, 2022
f58b8e1
add initial docs
hmacdope Nov 12, 2022
07016f5
move to using _run backend
hmacdope Nov 20, 2022
908f6fe
add upcast back in
hmacdope Nov 21, 2022
072b743
fix yml CI files
hmacdope Nov 21, 2022
05fe804
change test_pairwise_dist to use allclose rather than equals
hmacdope Nov 21, 2022
1d1300c
change another test to sue assert allclose
hmacdope Nov 21, 2022
a0e1dab
improve docs
hmacdope Nov 24, 2022
3d37504
change distance tests to use distopia backend
hmacdope Nov 24, 2022
22ebd40
split numpy compliance test
hmacdope Nov 24, 2022
8bfc5fc
changelog
hmacdope Nov 25, 2022
5188e15
Merge remote-tracking branch 'upstream/develop' into Add_distopia
hmacdope Nov 25, 2022
43bf661
fix merge issue in changelog
hmacdope Nov 25, 2022
ec76375
add note on varying precision to docs
hmacdope Nov 25, 2022
c9c024e
Merge branch 'develop' into Add_distopia
IAlibay Dec 1, 2022
5889c87
Merge branch 'develop' into Add_distopia
IAlibay Dec 9, 2022
1610cd3
Update testsuite/MDAnalysisTests/lib/test_distances.py
hmacdope Dec 13, 2022
3ff2489
Merge remote-tracking branch 'upstream/develop' into Add_distopia
hmacdope Dec 13, 2022
404e8ba
add warning for triclinic boxes
hmacdope Dec 13, 2022
f237024
darker
hmacdope Dec 13, 2022
9042102
add second importlib try block
hmacdope Dec 13, 2022
56e5091
return callable or ndarray
hmacdope Dec 13, 2022
142cca1
Revert "return callable or ndarray"
hmacdope Dec 13, 2022
773153e
Merge branch 'develop' into Add_distopia
IAlibay Dec 15, 2022
9ee8668
Merge branch 'develop' into Add_distopia
IAlibay Jan 5, 2023
a5bcc63
change docs on default
hmacdope Jan 7, 2023
9ad10b9
start of stub
hmacdope Jan 7, 2023
46f471c
Update package/MDAnalysis/lib/distances.py
hmacdope Jan 7, 2023
9105b0b
add align
hmacdope Jan 7, 2023
1f9e5d5
WIP on stub
hmacdope Jan 7, 2023
e91d4e8
finalise distopia stub
hmacdope Jan 8, 2023
402b90c
change calc_bonds to use distopia stub
hmacdope Jan 8, 2023
f7b79fc
fix type annotation
hmacdope Jan 8, 2023
416afcc
Merge remote-tracking branch 'upstream/develop' into Add_distopia
hmacdope Jan 8, 2023
1ec7445
darker
hmacdope Jan 8, 2023
9e0ea7d
darker distances.py
hmacdope Jan 8, 2023
9ff3ecf
try to make black happier again
hmacdope Jan 8, 2023
e2d606f
fix distances.py again
hmacdope Jan 8, 2023
028f548
finally fix everything
hmacdope Jan 8, 2023
ec04406
fix versionchanged
hmacdope Jan 8, 2023
8f98806
remove try except
hmacdope Jan 8, 2023
e185b7a
Update package/MDAnalysis/lib/distances.py
hmacdope Jan 8, 2023
cba5b5f
Merge remote-tracking branch 'upstream/develop' into Add_distopia
hmacdope Jan 19, 2023
ea8185b
Merge remote-tracking branch 'upstream/develop' into Add_distopia
hmacdope Jan 26, 2023
403b7e6
finalise merge
hmacdope Jan 26, 2023
04bb71b
Merge branch 'develop' into Add_distopia
IAlibay Feb 13, 2023
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
33 changes: 27 additions & 6 deletions package/MDAnalysis/lib/distances.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@
from .c_distances import _minimize_vectors_ortho, _minimize_vectors_triclinic


try:
import distopia
except ImportError:
HAS_DISTOPIA = False
else:
HAS_DISTOPIA = True

# hack to select backend with backend=<backend> kwarg. Note that
# the cython parallel code (prange) in parallel.distances is
# independent from the OpenMP code
Expand Down Expand Up @@ -1432,6 +1439,8 @@ def calc_bonds(coords1: Union[np.ndarray, 'AtomGroup'],
.. versionchanged:: 2.3.0
Can now accept an :class:`~MDAnalysis.core.groups.AtomGroup` as an
argument in any position and checks inputs using type hinting.
.. versionchanged:: 2.4.0
Can use the fast distance functions from distopia
"""
numatom = coords1.shape[0]
bondlengths = _check_result_array(result, (numatom,))
Expand All @@ -1440,17 +1449,29 @@ def calc_bonds(coords1: Union[np.ndarray, 'AtomGroup'],
if box is not None:
boxtype, box = check_box(box)
if boxtype == 'ortho':
_run("calc_bond_distance_ortho",
args=(coords1, coords2, box, bondlengths),
backend=backend)
if HAS_DISTOPIA:
bondlengths = distopia.calc_bonds_ortho_float(coords1, coords2, box[:3],
results=bondlengths.astype(np.float32))
# upcast is currently required
bondlengths = bondlengths.astype(np.float64)
else:
_run("calc_bond_distance_ortho",
args=(coords1, coords2, box, bondlengths),
backend=backend)
else:
_run("calc_bond_distance_triclinic",
args=(coords1, coords2, box, bondlengths),
backend=backend)
else:
_run("calc_bond_distance",
args=(coords1, coords2, bondlengths),
backend=backend)
if HAS_DISTOPIA:
bondlengths = distopia.calc_bonds_no_box_float(coords1, coords2,
results=bondlengths.astype(np.float32))
# upcast is currently required
bondlengths = bondlengths.astype(np.float64)
else:
_run("calc_bond_distance",
args=(coords1, coords2, bondlengths),
backend=backend)

return bondlengths

Expand Down