summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/_add_newdocs.py3
-rw-r--r--numpy/core/fromnumeric.py3
-rw-r--r--numpy/core/src/multiarray/getset.c4
3 files changed, 6 insertions, 4 deletions
diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py
index e51755101..ba5c0fa68 100644
--- a/numpy/core/_add_newdocs.py
+++ b/numpy/core/_add_newdocs.py
@@ -2314,7 +2314,8 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('shape',
>>> np.zeros((4,2))[::2].shape = (-1,)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
- AttributeError: incompatible shape for a non-contiguous array
+ AttributeError: Incompatible shape for in-place modification. Use
+ `.reshape()` to make a copy with the desired shape.
See Also
--------
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index acd2d2bea..b32ad8d35 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -252,7 +252,8 @@ def reshape(a, newshape, order='C'):
>>> c.shape = (20)
Traceback (most recent call last):
...
- AttributeError: incompatible shape for a non-contiguous array
+ AttributeError: Incompatible shape for in-place modification. Use
+ `.reshape()` to make a copy with the desired shape.
The `order` keyword gives the index ordering both for *fetching* the values
from `a`, and then *placing* the values into the output array.
diff --git a/numpy/core/src/multiarray/getset.c b/numpy/core/src/multiarray/getset.c
index 9a9c51fee..5b7362153 100644
--- a/numpy/core/src/multiarray/getset.c
+++ b/numpy/core/src/multiarray/getset.c
@@ -62,8 +62,8 @@ array_shape_set(PyArrayObject *self, PyObject *val)
if (PyArray_DATA(ret) != PyArray_DATA(self)) {
Py_DECREF(ret);
PyErr_SetString(PyExc_AttributeError,
- "incompatible shape for a non-contiguous "\
- "array");
+ "Incompatible shape for in-place modification. Use "
+ "`.reshape()` to make a copy with the desired shape.");
return -1;
}