8000 BUG: Make advanced indexing result on read-only subclass writeable by jeremiedbb · Pull Request #14171 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Make advanced indexing result on read-only subclass writeable #14171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
do not use original array flags in fancy indexing
  • Loading branch information
jeremiedbb committed Jul 31, 2019
commit 3fe766d296b971dfa150b536a5ba37ebb2c345c8
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
13 changes: 13 additions & 0 deletions numpy/core/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,19 @@ class SubClass(np.ndarray):
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.setflags(write=False)
s_fancy = s[[0, 1, 2]]
assert_(s_fancy.flags['WRITEABLE'])


4612 def test_finalize_gets_full_info(self):
# Array finalize should be called on the filled array.
class SubClass(np.ndarray):
Expand Down
0