diff options
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/src/multiarray/mapping.c | 2 | ||||
-rw-r--r-- | numpy/core/tests/test_indexing.py | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c index add1143b2..9bb85e320 100644 --- a/numpy/core/src/multiarray/mapping.c +++ b/numpy/core/src/multiarray/mapping.c @@ -1699,7 +1699,7 @@ array_subscript(PyArrayObject *self, PyObject *op) PyArray_SHAPE(tmp_arr), PyArray_STRIDES(tmp_arr), PyArray_BYTES(tmp_arr), - PyArray_FLAGS(self), + PyArray_FLAGS(tmp_arr), (PyObject *)self, (PyObject *)tmp_arr); Py_DECREF(tmp_arr); if (result == NULL) { diff --git a/numpy/core/tests/test_indexing.py b/numpy/core/tests/test_indexing.py index f7485c3f7..70a5a246f 100644 --- a/numpy/core/tests/test_indexing.py +++ b/numpy/core/tests/test_indexing.py @@ -617,6 +617,19 @@ class TestSubclasses(object): assert_array_equal(s_bool, a[a > 0]) assert_array_equal(s_bool.base, a[a > 0]) + def test_fancy_on_read_only(self): + # Test that fancy indexing on read-only SubClass does not make a + # read-only copy (gh-14132) + class SubClass(np.ndarray): + pass + + a = np.arange(5) + s = a.view(SubClass) + s.flags.writeable = False + s_fancy = s[[0, 1, 2]] + assert_(s_fancy.flags.writeable) + + def test_finalize_gets_full_info(self): # Array finalize should be called on the filled array. class SubClass(np.ndarray): |