Skip to content

Commit 0b4fcd9

Browse files
committed
Don't perform the reshape in-place when copy=False for numpy and cupy
1 parent de68781 commit 0b4fcd9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

array_api_compat/common/_aliases.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def _asarray(
331331

332332
return xp.asarray(obj, dtype=dtype, **kwargs)
333333

334-
# xp.reshape calls the keyword argument 'newshape' instead of 'shape'
334+
# np.reshape calls the keyword argument 'newshape' instead of 'shape'
335335
def reshape(x: ndarray,
336336
/,
337337
shape: Tuple[int, ...],
@@ -340,8 +340,9 @@ def reshape(x: ndarray,
340340
if copy is True:
341341
x = x.copy()
342342
elif copy is False:
343-
x.shape = shape
344-
return x
343+
y = x.view()
344+
y.shape = shape
345+
return y
345346
return xp.reshape(x, shape, **kwargs)
346347

347348
# The descending keyword is new in sort and argsort, and 'kind' replaced with

0 commit comments

Comments
 (0)