summaryrefslogtreecommitdiff
path: root/numpy/core/fromnumeric.py
diff options
context:
space:
mode:
authorJoryKlaverstijn <63673224+JoryKlaverstijn@users.noreply.github.com>2023-03-31 16:38:15 +0200
committerGitHub <noreply@github.com>2023-03-31 16:38:15 +0200
commit700211a7af88afa225ef0d8332c575c8aae813de (patch)
tree98606f218bb745ebe19916ff0b2cd85ed7f5ed65 /numpy/core/fromnumeric.py
parentb50568d9e758b489c2a3c409ef4e57b67820f090 (diff)
downloadnumpy-700211a7af88afa225ef0d8332c575c8aae813de.tar.gz
DOC: Removed `.shape` setting note from reshape (#23491)
* DOC: Changed the example for modifying the shape without modifying the initial object * DOC: Removed the example for directly assigning a tuple to the shape attribute of a numpy array * DOC: Re-added note about copying data when reshaping an array to numpy.reshape docs * DOC: reformat for linting --------- Co-authored-by: Jory Klaverstijn <j.klaverstijn@student.rug.nl> Co-authored-by: Matti Picus <matti.picus@gmail.com>
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r--numpy/core/fromnumeric.py21
1 files changed, 3 insertions, 18 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index 88c66d9a4..4608bc6de 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -238,24 +238,9 @@ def reshape(a, newshape, order='C'):
Notes
-----
- It is not always possible to change the shape of an array without
- copying the data. If you want an error to be raised when the data is copied,
- you should assign the new shape to the shape attribute of the array::
-
- >>> a = np.zeros((10, 2))
-
- # A transpose makes the array non-contiguous
- >>> b = a.T
-
- # Taking a view makes it possible to modify the shape without modifying
- # the initial object.
- >>> c = b.view()
- >>> c.shape = (20)
- Traceback (most recent call last):
- ...
- AttributeError: Incompatible shape for in-place modification. Use
- `.reshape()` to make a copy with the desired shape.
-
+ It is not always possible to change the shape of an array without copying
+ the data.
+
The `order` keyword gives the index ordering both for *fetching* the values
from `a`, and then *placing* the values into the output array.
For example, let's say you have an array: