Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
23 changes: 23 additions & 0 deletions news/numpy2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* support for numpy >=2.0

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* element/label itemsize to 5 in _linkAtomAttribute to support numpy >=2.0

**Security:**

* <news item>
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