Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e54990c

Browse files
DOC: Update reshape docstring to clarify it returns a new array (#31440)
Co-authored-by: Apex-Shubham <[email protected]>
1 parent bba3954 commit e54990c

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

doc/source/user/absolute_beginners.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ Can you reshape an array?
406406

407407
**Yes!**
408408

409-
Using ``arr.reshape()`` will give a new shape to an array without changing the
409+
Using ``arr.reshape()`` will return a reshaped array without changing the
410410
data. Just remember that when you use the reshape method, the array you want to
411411
produce needs to have the same number of elements as the original array. If you
412412
start with an array with 12 elements, you'll need to make sure that your new

numpy/_core/_add_newdocs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4749,7 +4749,7 @@ def _array_method_doc(name: str, params: str, doc: str) -> None:
47494749
--------
47504750
transpose : Equivalent function.
47514751
ndarray.T : Array property returning the array transposed.
4752-
ndarray.reshape : Give a new shape to an array without changing its data.
4752+
ndarray.reshape : Return a reshaped ndarray without changing data.
47534753
47544754
Examples
47554755
--------

numpy/_core/fromnumeric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def _reshape_dispatcher(a, /, shape, order=None, *, copy=None):
207207
@array_function_dispatch(_reshape_dispatcher)
208208
def reshape(a, /, shape, order='C', *, copy=None):
209209
"""
210-
Gives a new shape to an array without changing its data.
210+
Returns a reshaped ndarray without changing data.
211211
212212
Parameters
213213
----------

numpy/ma/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4751,7 +4751,7 @@ def ravel(self, order='C'):
47514751

47524752
def reshape(self, *s, **kwargs):
47534753
"""
4754-
Give a new shape to the array without changing its data.
4754+
Returns a reshaped masked array without changing its data.
47554755
47564756
Returns a masked array containing the same data, but with a new shape.
47574757
The result is a view on the original array; if this is not possible, a

0 commit comments

Comments
 (0)