Skip to content

Commit

Permalink
MAINT: Fix for NumPy 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Mar 4, 2024
1 parent acd0c77 commit d2b708f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nibabel/arrayproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ def ndim(self) -> int:

# If no dtype is passed, any dtype might be returned, depending on the array-like
@ty.overload
def __array__(self, dtype: None = ..., /) -> np.ndarray[ty.Any, np.dtype[ty.Any]]:
def __array__(self, dtype: None = ..., /, copy: bool=False) -> np.ndarray[ty.Any, np.dtype[ty.Any]]:
... # pragma: no cover

# Any dtype might be passed, and *that* dtype must be returned
@ty.overload
def __array__(self, dtype: _DType, /) -> np.ndarray[ty.Any, _DType]:
def __array__(self, dtype: _DType, /, copy: bool=False) -> np.ndarray[ty.Any, _DType]:
... # pragma: no cover

def __getitem__(self, key, /) -> npt.NDArray:
Expand Down Expand Up @@ -433,7 +433,7 @@ def get_unscaled(self):
"""
return self._get_unscaled(slicer=())

def __array__(self, dtype=None):
def __array__(self, dtype=None, *, copy=False):
"""Read data from file and apply scaling, casting to ``dtype``
If ``dtype`` is unspecified, the dtype of the returned array is the
Expand All @@ -456,7 +456,7 @@ def __array__(self, dtype=None):
"""
arr = self._get_scaled(dtype=dtype, slicer=())
if dtype is not None:
arr = arr.astype(dtype, copy=False)
arr = arr.astype(dtype, copy=copy)
return arr

def __getitem__(self, slicer):
Expand Down

0 comments on commit d2b708f

Please sign in to comment.