diff options
author | seberg <sebastian@sipsolutions.net> | 2016-02-18 22:09:24 +0100 |
---|---|---|
committer | seberg <sebastian@sipsolutions.net> | 2016-02-18 22:09:24 +0100 |
commit | 4991e212422eeef6b5223ccdcf093a27db550e95 (patch) | |
tree | 4802bc316b0f222a8a5cf6422decb8464105b482 | |
parent | ec5bd813061ceb766cf78d04c6d72a80804110e0 (diff) | |
parent | 0f4f8807b93375b14856d3b34a0dea73bdb64b73 (diff) | |
download | numpy-4991e212422eeef6b5223ccdcf093a27db550e95.tar.gz |
Merge pull request #7278 from gfyoung/unravel_writable
BUG: Make returned unravel_index arrays writeable
-rw-r--r-- | numpy/core/src/multiarray/compiled_base.c | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test_index_tricks.py | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/compiled_base.c b/numpy/core/src/multiarray/compiled_base.c index b9db3bb8f..932b94f15 100644 --- a/numpy/core/src/multiarray/compiled_base.c +++ b/numpy/core/src/multiarray/compiled_base.c @@ -1234,7 +1234,7 @@ arr_unravel_index(PyObject *self, PyObject *args, PyObject *kwds) ret_dims, NPY_INTP, ret_strides, PyArray_BYTES(ret_arr) + i*sizeof(npy_intp), - 0, 0, NULL); + 0, NPY_ARRAY_WRITEABLE, NULL); if (view == NULL) { goto fail; } diff --git a/numpy/lib/tests/test_index_tricks.py b/numpy/lib/tests/test_index_tricks.py index bb2ae1509..919791ae5 100644 --- a/numpy/lib/tests/test_index_tricks.py +++ b/numpy/lib/tests/test_index_tricks.py @@ -86,6 +86,12 @@ class TestRavelUnravelIndex(TestCase): assert_raises( ValueError, np.ravel_multi_index, [5, 1, -1, 2], (4, 3, 7, 12)) + def test_writeability(self): + # See gh-7269 + x, y = np.unravel_index([1, 2, 3], (4, 5)) + self.assertTrue(x.flags.writeable) + self.assertTrue(y.flags.writeable) + class TestGrid(TestCase): def test_basic(self): |