summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/mapping.c6
-rw-r--r--numpy/core/tests/test_indexing.py11
2 files changed, 17 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c
index e2b8ef700..87720e692 100644
--- a/numpy/core/src/multiarray/mapping.c
+++ b/numpy/core/src/multiarray/mapping.c
@@ -1058,6 +1058,9 @@ array_boolean_subscript(PyArrayObject *self,
Py_DECREF(ret);
return NULL;
}
+ if (_IsWriteable(ret)) {
+ PyArray_ENABLEFLAGS(ret, NPY_ARRAY_WRITEABLE);
+ }
}
return ret;
@@ -1583,6 +1586,9 @@ array_subscript(PyArrayObject *self, PyObject *op)
result = NULL;
goto finish;
}
+ if (_IsWriteable(result)) {
+ PyArray_ENABLEFLAGS(result, NPY_ARRAY_WRITEABLE);
+ }
}
finish:
diff --git a/numpy/core/tests/test_indexing.py b/numpy/core/tests/test_indexing.py
index 6b0b0a0b5..02ef8dace 100644
--- a/numpy/core/tests/test_indexing.py
+++ b/numpy/core/tests/test_indexing.py
@@ -285,6 +285,17 @@ class TestIndexing(TestCase):
assert_((a == 1).all())
+ def test_subclass_writeable(self):
+ d = np.rec.array([('NGC1001', 11), ('NGC1002', 1.), ('NGC1003', 1.)],
+ dtype=[('target', 'S20'), ('V_mag', '>f4')])
+ ind = np.array([False, True, True], dtype=bool)
+ assert_(d[ind].flags.writeable)
+ ind = np.array([0, 1])
+ assert_(d[ind].flags.writeable)
+ assert_(d[...].flags.writeable)
+ assert_(d[0].flags.writeable)
+
+
def test_memory_order(self):
# This is not necessary to preserve. Memory layouts for
# more complex indices are not as simple.