Skip to content

Numpy >=2.0 support with depreciation warning removed #102

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

Merged
merged 6 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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 pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=62.0", "setuptools-git-versioning<2"]
requires = ["setuptools>=62.0", "setuptools-git-versioning>=2.0"]
build-backend = "setuptools.build_meta"

[project]
Expand Down
2 changes: 1 addition & 1 deletion requirements/run.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
numpy < 2.0.0 # Need to fix deprecations before 2.0.0 compat
numpy
pycifrw
2 changes: 1 addition & 1 deletion src/diffpy/structure/atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def __setitem__(self, idx, value):
self._atom.xyz[:] = self._atom.lattice.fractional(self)
return

def __array_wrap__(self, out_arr, context=None):
def __array_wrap__(self, out_arr, context=None, return_scalar=None):
"""Ensure math operations on this type yield standard numpy array."""
return out_arr.view(numpy.ndarray)

Expand Down
10 changes: 6 additions & 4 deletions src/diffpy/structure/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,8 +711,9 @@ def _get_composition(self):
element = _linkAtomAttribute(
"element",
"""Character array of `Atom` types. Assignment updates
the element attribute of the respective `Atoms`.""",
toarray=numpy.char.array,
the element attribute of the respective `Atoms`.
Set the maximum length of the element string to 5 characters.""",
toarray=lambda items: numpy.char.array(items, itemsize=5),
)

xyz = _linkAtomAttribute(
Expand Down Expand Up @@ -742,8 +743,9 @@ def _get_composition(self):
label = _linkAtomAttribute(
"label",
"""Character array of `Atom` names. Assignment updates
the label attribute of all `Atoms`.""",
toarray=numpy.char.array,
the label attribute of all `Atoms`.
Set the maximum length of the label string to 5 characters.""",
toarray=lambda items: numpy.char.array(items, itemsize=5),
)

occupancy = _linkAtomAttribute(
Expand Down