Skip to content

Commit

Permalink
Merge pull request #210 from Z2h-A6n/numpy2-alias-removal-fix
Browse files Browse the repository at this point in the history
Fix NumPy 2.x compatibility: replace `np.string_` with `np.bytes_`
  • Loading branch information
rayosborn authored Jun 21, 2024
2 parents 7a40a56 + d75e614 commit f0db0ac
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/nexusformat/nexus/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1864,7 +1864,7 @@ def __unicode__(self):
def __repr__(self):
if (self.dtype is not None and
(self.shape == () or self.shape == (1,)) and
(self.dtype.type == np.string_ or self.dtype.type == np.str_ or
(self.dtype.type == np.bytes_ or self.dtype.type == np.str_ or
self.dtype == string_dtype)):
return f"NXattr('{self}')"
else:
Expand Down Expand Up @@ -1898,7 +1898,7 @@ def nxvalue(self):
if self._value is None:
return ''
elif (self.dtype is not None and
(self.dtype.type == np.string_ or self.dtype.type == np.str_ or
(self.dtype.type == np.bytes_ or self.dtype.type == np.str_ or
self.dtype == string_dtype)):
if self.shape == ():
return text(self._value)
Expand Down Expand Up @@ -3280,7 +3280,7 @@ def __array__(self, *args, **kwargs):
"""Cast the NXfield as a NumPy array."""
return np.asarray(self.nxdata, *args, **kwargs)

def __array_wrap__(self, value, context=None):
def __array_wrap__(self, value, context=None, return_scalar=False):
"""Transform the array resulting from a ufunc to an NXfield."""
return NXfield(value, name=self.nxname)

Expand Down Expand Up @@ -3721,7 +3721,7 @@ def nxvalue(self):
if _value is None:
return None
elif (self.dtype is not None and
(self.dtype.type == np.string_ or self.dtype.type == np.str_ or
(self.dtype.type == np.bytes_ or self.dtype.type == np.str_ or
self.dtype == string_dtype)):
if self.shape == ():
return text(_value)
Expand Down

0 comments on commit f0db0ac

Please sign in to comment.