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

Fix NumPy 2.x compatibility: replace np.string_ with np.bytes_ #210

Merged
merged 2 commits into from
Jun 21, 2024
Merged
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
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
Loading