@@ -206,28 +206,28 @@ def take(a, indices, axis=None, out=None, mode='raise'):
206
206
return _wrapfunc (a , 'take' , indices , axis = axis , out = out , mode = mode )
207
207
208
208
209
- def _reshape_dispatcher (a , / , newshape = None , shape = None , * ,
210
- order = None , copy = None ):
209
+ def _reshape_dispatcher (a , / , shape = None , * , newshape = None , order = None ,
210
+ copy = None ):
211
211
return (a ,)
212
212
213
213
214
214
@array_function_dispatch (_reshape_dispatcher )
215
- def reshape (a , / , newshape = None , shape = None , * , order = 'C' , copy = None ):
215
+ def reshape (a , / , shape = None , * , newshape = None , order = 'C' , copy = None ):
216
216
"""
217
217
Gives a new shape to an array without changing its data.
218
218
219
219
Parameters
220
220
----------
221
221
a : array_like
222
222
Array to be reshaped.
223
- newshape : int or tuple of ints
224
- Replaced by ``shape`` argument. Retained for backward
225
- compatibility.
226
223
shape : int or tuple of ints
227
224
The new shape should be compatible with the original shape. If
228
225
an integer, then the result will be a 1-D array of that length.
229
226
One shape dimension can be -1. In this case, the value is
230
227
inferred from the length of the array and remaining dimensions.
228
+ newshape : int or tuple of ints
229
+ Replaced by ``shape`` argument. Retained for backward
230
+ compatibility.
231
231
order : {'C', 'F', 'A'}, optional
232
232
Read the elements of ``a`` using this index order, and place the
233
233
elements into the reshaped array using this index order. 'C'
@@ -310,9 +310,17 @@ def reshape(a, /, newshape=None, shape=None, *, order='C', copy=None):
310
310
raise ValueError (
311
311
"You cannot specify 'newshape' and 'shape' arguments "
312
312
"at the same time." )
313
- if shape is not None :
314
- newshape = shape
315
- return _wrapfunc (a , 'reshape' , newshape , order = order , copy = copy )
313
+ if newshape is not None :
314
+ # Deprecated in NumPy 2.1, 2024-04-18
315
+ warnings .warn (
316
+ "`newshape` keyword argument is deprecated, "
317
+ "use `shape=...` or pass shape positionally instead. "
318
+ "(deprecated in NumPy 2.1)" ,
319
+ DeprecationWarning ,
320
+ stacklevel = 2 ,
321
+ )
322
+ shape = newshape
323
+ return _wrapfunc (a , 'reshape' , shape , order = order , copy = copy )
316
324
317
325
318
326
def _choose_dispatcher (a , choices , out = None , mode = None ):
0 commit comments