Skip to content

Commit 4c4405b

Browse files
committed
Add ArrayProxy.reshape
1 parent ca977ab commit 4c4405b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

nibabel/arrayproxy.py

+11
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,17 @@ def __getitem__(self, slicer):
162162
# Upcast as necessary for big slopes, intercepts
163163
return apply_read_scaling(raw_data, self._slope, self._inter)
164164

165+
def reshape(self, shape):
166+
size = np.prod(self._shape)
167+
if np.prod(shape) != size:
168+
raise ValueError("cannot reshape array of size {:d} into shape "
169+
"{!s}".format(size, shape))
170+
new_ap = ArrayProxy(file_like=self.file_like,
171+
header=self._header,
172+
mmap=self._mmap)
173+
new_ap.shape = shape
174+
return new_ap
175+
165176

166177
def is_proxy(obj):
167178
""" Return True if `obj` is an array proxy

0 commit comments

Comments
 (0)