8000 Merge pull request #4847 from juliantaylor/writeable2 · numpy/numpy@d244ec7 · GitHub
[go: up one dir, main page]

Skip to content

Commit d244ec7

Browse files
committed
Merge pull request #4847 from juliantaylor/writeable2
better writeable flag fix
2 parents 1c71d46 + 4352957 commit d244ec7

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

numpy/core/src/multiarray/mapping.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ array_boolean_subscript(PyArrayObject *self,
10471047
Py_INCREF(dtype);
10481048
ret = (PyArrayObject *)PyArray_NewFromDescr(Py_TYPE(self), dtype, 1,
10491049
&size, PyArray_STRIDES(ret), PyArray_BYTES(ret),
1050-
0, (PyObject *)self);
1050+
PyArray_FLAGS(self), (PyObject *)self);
10511051

10521052
if (ret == NULL) {
10531053
Py_DECREF(tmp);
@@ -1058,9 +1058,6 @@ array_boolean_subscript(PyArrayObject *self,
10581058
Py_DECREF(ret);
10591059
return NULL;
10601060
}
1061-
if (_IsWriteable(ret)) {
1062-
PyArray_ENABLEFLAGS(ret, NPY_ARRAY_WRITEABLE);
1063-
}
10641061
}
10651062

10661063
return ret;
@@ -1572,7 +1569,7 @@ array_subscript(PyArrayObject *self, PyObject *op)
15721569
PyArray_SHAPE(tmp_arr),
15731570
PyArray_STRIDES(tmp_arr),
15741571
PyArray_BYTES(tmp_arr),
1575-
0, /* TODO: Flags? */
1572+
PyArray_FLAGS(self),
15761573
(PyObject *)self);
15771574

15781575
if (result == NULL) {
@@ -1586,9 +1583,6 @@ array_subscript(PyArrayObject *self, PyObject *op)
15861583
result = NULL;
15871584
goto finish;
15881585
}
1589-
if (_IsWriteable(result)) {
1590-
PyArray_ENABLEFLAGS(result, NPY_ARRAY_WRITEABLE);
1591-
}
15921586
}
15931587

15941588
finish:
@@ -1813,7 +1807,8 @@ array_assign_subscript(PyArrayObject *self, PyObject *ind, PyObject *op)
18131807
* check to allow wrong dimensional boolean arrays in all cases.
18141808
*/
18151809
if (PyArray_NDIM(tmp_arr) > 1) {
1816-
if (attempt_1d_fallback(self, indices[0].object, tmp_arr) < 0) {
1810+
if (attempt_1d_fallback(self, indices[0].object,
1811+
(PyObject*)tmp_arr) < 0) {
18171812
goto fail;
18181813
}
18191814
goto success;

0 commit comments

Comments
 (0)
0