Skip to content

Commit 88e811b

Browse files
committed
Add the copy keyword argument to reshape
1 parent 2ba3411 commit 88e811b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

numpy_array_api_compat/_aliases.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,12 @@ def zeros_like(
269269
return np.zeros_like(x, dtype=dtype)
270270

271271
# np.reshape calls the keyword argument 'newshape' instead of 'shape'
272-
def reshape(x: ndarray, /, shape: Tuple[int, ...]) -> ndarray:
272+
def reshape(x: ndarray, /, shape: Tuple[int, ...], copy: Optional[bool] = None) -> ndarray:
273+
if copy is True:
274+
x = x.copy()
275+
elif copy is False:
276+
x.shape = shape
277+
return x
273278
return np.reshape(x, shape)
274279

275280
# from numpy import * doesn't overwrite these builtin names

0 commit comments

Comments
 (0)