Skip to content
Snippets Groups Projects
Commit b9f8ddb3 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

MNT: np.array(a, copy=False) raises an error in numpy 2 if the array cannot be copied

parent 37be45ab
No related branches found
No related tags found
No related merge requests found
......@@ -179,7 +179,7 @@ class Bitmap(object):
for ci, ch in enumerate(dtype.names):
data[ch] = self.data[..., ci]
data = np.array(data, order='F', copy=False)
data = np.asarray(data, order='F')
return fslimage.Image(data,
name=self.name,
......
......@@ -62,7 +62,7 @@ def veclength(vec):
Multiple vectors may be passed in, with a shape of ``(n, 3)``.
"""
vec = np.array(vec, copy=False).reshape(-1, 3)
vec = np.asarray(vec).reshape(-1, 3)
return np.sqrt(np.einsum('ij,ij->i', vec, vec))
......@@ -71,7 +71,7 @@ def normalise(vec):
Multiple vectors may be passed in, with a shape of ``(n, 3)``.
"""
vec = np.array(vec, copy=False).reshape(-1, 3)
vec = np.asarray(vec).reshape(-1, 3)
n = (vec.T / veclength(vec)).T
if n.size == 3:
......
......@@ -190,7 +190,7 @@ def resample(image,
if origin not in ('centre', 'corner'):
raise ValueError('Invalid value for origin: {}'.format(origin))
data = np.array(image[sliceobj], dtype=dtype, copy=False)
data = np.asarray(image[sliceobj], dtype=dtype)
if len(data.shape) != len(newShape):
raise ValueError('Data dimensions do not match new shape: '
......
......@@ -242,8 +242,8 @@ def skipUnchanged(func):
isarray = oldIsArray or newIsArray
if isarray:
a = np.array(oldVal, copy=False)
b = np.array(value, copy=False)
a = np.asarray(oldVal)
b = np.asarray(value)
nochange = (a.shape == b.shape) and np.allclose(a, b)
else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment