Skip to content

Commit

Permalink
Merge branch 'develop' into feature/dask-0
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxuanzhuang authored Apr 28, 2024
2 parents a8e0ccc + 804b607 commit ab394a4
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 21 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/gh-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.xml
fail_ci_if_error: True
fail_ci_if_error: False
verbose: True


Expand Down Expand Up @@ -259,22 +259,22 @@ jobs:
- name: check_package_build
run: |
DISTRIBUTION=$(ls -t1 dist/MDAnalysis-*.tar.gz | head -n1)
DISTRIBUTION=$(ls -t1 dist/mdanalysis-*.tar.gz | head -n1)
test -n "${DISTRIBUTION}" || { echo "no distribution dist/MDAnalysis-*.tar.gz found"; exit 1; }
twine check $DISTRIBUTION
- name: check_testsuite_build
run: |
DISTRIBUTION=$(ls -t1 dist/MDAnalysisTests-*.tar.gz | head -n1)
DISTRIBUTION=$(ls -t1 dist/mdanalysistests-*.tar.gz | head -n1)
test -n "${DISTRIBUTION}" || { echo "no distribution dist/MDAnalysisTests-*.tar.gz found"; exit 1; }
twine check $DISTRIBUTION
- name: install sdist
working-directory: ./dist
run: |
ls -a .
python -m pip install MDAnalysis-*.tar.gz
python -m pip install MDAnalysisTests-*.tar.gz
python -m pip install mdanalysis-*.tar.gz
python -m pip install mdanalysistests-*.tar.gz
- name: run tests
working-directory: ./dist
Expand Down
13 changes: 6 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,18 @@ Citation
When using MDAnalysis in published work, please cite the following
two papers:

* R. J. Gowers, M. Linke, J. Barnoud, T. J. E. Reddy,
M. N. Melo, S. L. Seyler, D. L. Dotson, J. Domanski,
S. Buchoux, I. M. Kenney, and O. Beckstein. MDAnalysis:
* R\. J. Gowers, M. Linke, J. Barnoud, T. J. E. Reddy,
M\. N. Melo, S. L. Seyler, D. L. Dotson, J. Domanski,
S\. Buchoux, I. M. Kenney, and O. Beckstein. MDAnalysis:
A Python package for the rapid analysis of molecular
dynamics simulations. In S. Benthall and S. Rostrup,
editors, Proceedings of the 15th Python in Science
Conference, pages 102-109, Austin, TX, 2016. SciPy.
doi:`10.25080/Majora-629e541a-00e`_

doi: `10.25080/Majora-629e541a-00e`_
* N. Michaud-Agrawal, E. J. Denning, T. B. Woolf,
and O. Beckstein. MDAnalysis: A Toolkit for the Analysis of Molecular
Dynamics Simulations. *J. Comput. Chem.* **32** (2011), 2319--2327.
doi:`10.1002/jcc.21787`_
doi: `10.1002/jcc.21787`_

For citations of included algorithms and sub-modules please see the references_.

Expand Down Expand Up @@ -194,4 +193,4 @@ For citations of included algorithms and sub-modules please see the references_.

.. |discussions| image:: https://img.shields.io/github/discussions/MDAnalysis/MDAnalysis
:alt: GitHub Discussions
:target: https://github.com/MDAnalysis/mdanalysis/discussions
:target: https://github.com/MDAnalysis/mdanalysis/discussions
2 changes: 1 addition & 1 deletion package/MDAnalysis/analysis/helix_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def vector_of_best_fit(coordinates):
"""
centered = coordinates - coordinates.mean(axis=0)
Mt_M = np.matmul(centered.T, centered)
u, s, vh = np.linalg.linalg.svd(Mt_M)
u, s, vh = np.linalg.svd(Mt_M)
vector = vh[0]

# does vector face first local helix origin?
Expand Down
6 changes: 4 additions & 2 deletions package/MDAnalysis/lib/formats/cython_util.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ cimport numpy as cnp
from libc.stdlib cimport free
from cpython cimport PyObject, Py_INCREF

from MDAnalysis.lib.util import no_copy_shim

cnp.import_array()


Expand Down Expand Up @@ -71,7 +73,7 @@ cdef class ArrayWrapper:
self.data_type = data_type
self.ndim = ndim

def __array__(self):
def __array__(self, dtype=None, copy=None):
""" Here we use the __array__ method, that is called when numpy
tries to get an array from the object."""
ndarray = cnp.PyArray_SimpleNewFromData(self.ndim,
Expand Down Expand Up @@ -110,7 +112,7 @@ cdef cnp.ndarray ptr_to_ndarray(void* data_ptr, cnp.int64_t[:] dim, int data_typ
array_wrapper = ArrayWrapper()
array_wrapper.set_data(<void*> data_ptr, <int*> &dim[0], dim.size, data_type)

cdef cnp.ndarray ndarray = np.array(array_wrapper, copy=False)
cdef cnp.ndarray ndarray = np.array(array_wrapper, copy=no_copy_shim)
# Assign our object to the 'base' of the ndarray object
ndarray[:] = array_wrapper.__array__()
# Increment the reference count, as the above assignement was done in
Expand Down
13 changes: 7 additions & 6 deletions package/MDAnalysis/lib/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
from numpy.linalg import norm

from .mdamath import angle as vecangle
from MDAnalysis.lib.util import no_copy_shim

def identity_matrix():
"""Return 4x4 identity/unit matrix.
Expand Down Expand Up @@ -326,7 +327,7 @@ def rotation_matrix(angle, direction, point=None):
M[:3, :3] = R
if point is not None:
# rotation not around origin
point = np.array(point[:3], dtype=np.float64, copy=False)
point = np.array(point[:3], dtype=np.float64, copy=no_copy_shim)
M[:3, 3] = point - np.dot(R, point)
return M

Expand Down Expand Up @@ -497,7 +498,7 @@ def projection_matrix(point, normal, direction=None,
"""
M = np.identity(4)
point = np.array(point[:3], dtype=np.float64, copy=False)
point = np.array(point[:3], dtype=np.float64, copy=no_copy_shim)
normal = unit_vector(normal[:3])
if perspective is not None:
# perspective projection
Expand All @@ -515,7 +516,7 @@ def projection_matrix(point, normal, direction=None,
M[3, 3] = np.dot(perspective, normal)
elif direction is not None:
# parallel projection
direction = np.array(direction[:3], dtype=np.float64, copy=False)
direction = np.array(direction[:3], dtype=np.float64, copy=no_copy_shim)
scale = np.dot(direction, normal)
M[:3, :3] -= np.outer(direction, normal) / scale
M[:3, 3] = direction * (np.dot(point, normal) / scale)
Expand Down Expand Up @@ -970,8 +971,8 @@ def superimposition_matrix(v0, v1, scaling=False, usesvd=True):
True
"""
v0 = np.array(v0, dtype=np.float64, copy=False)[:3]
v1 = np.array(v1, dtype=np.float64, copy=False)[:3]
v0 = np.array(v0, dtype=np.float64, copy=no_copy_shim)[:3]
v1 = np.array(v1, dtype=np.float64, copy=no_copy_shim)[:3]

if v0.shape != v1.shape or v0.shape[1] < 3:
raise ValueError("vector sets are of wrong shape or type")
Expand Down Expand Up @@ -1314,7 +1315,7 @@ def quaternion_from_matrix(matrix, isprecise=False):
True
"""
M = np.array(matrix, dtype=np.float64, copy=False)[:4, :4]
M = np.array(matrix, dtype=np.float64, copy=no_copy_shim)[:4, :4]
if isprecise:
q = np.empty((4, ), dtype=np.float64)
t = np.trace(M)
Expand Down
8 changes: 8 additions & 0 deletions package/MDAnalysis/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2555,6 +2555,14 @@ def wrapper(self, *args, **kwargs):
return wrapper


def no_copy_shim():
if np.lib.NumpyVersion >= "2.0.0rc1":
copy = None
else:
copy = False
return copy


def is_installed(modulename: str):
"""Checks if module is installed
Expand Down

0 comments on commit ab394a4

Please sign in to comment.