From a6e869b70b09df9381d341ed0d2b18f88d8fe3d6 Mon Sep 17 00:00:00 2001 From: Mark Wiebe Date: Thu, 28 Jul 2011 17:07:44 -0500 Subject: BUG: ma: Fix a bug in numpy.ma hardmasks, exposed by the boolean indexing rewrite --- numpy/core/src/multiarray/mapping.c | 4 ++-- numpy/ma/core.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'numpy') diff --git a/numpy/core/src/multiarray/mapping.c b/numpy/core/src/multiarray/mapping.c index cf294454d..d98f723a7 100644 --- a/numpy/core/src/multiarray/mapping.c +++ b/numpy/core/src/multiarray/mapping.c @@ -981,8 +981,8 @@ array_ass_boolean_subscript(PyArrayObject *self, if (size != PyArray_DIMS(v)[0]) { PyErr_Format(PyExc_TypeError, "NumPy boolean array indexing assignment " - "requires an input shape matching the number of True " - "values in the mask (%d) != (%d)", + "cannot assign %d input values to " + "the %d output values where the mask is true", (int)PyArray_DIMS(v)[0], (int)size); return -1; } diff --git a/numpy/ma/core.py b/numpy/ma/core.py index e2e954a97..fdd5d2705 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -3040,7 +3040,7 @@ class MaskedArray(ndarray): mindx = mask_or(_mask[indx], mval, copy=True) dindx = self._data[indx] if dindx.size > 1: - dindx[~mindx] = dval + np.copyto(dindx, dval, where=~mindx) elif mindx is nomask: dindx = dval ndarray.__setitem__(_data, indx, dindx) -- cgit v1.2.1