diff options
-rw-r--r-- | numpy/ma/core.py | 5 | ||||
-rw-r--r-- | numpy/ma/tests/test_core.py | 11 |
2 files changed, 11 insertions, 5 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index b69424094..5684bf8fd 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -5586,9 +5586,8 @@ class mvoid(MaskedArray): """ # def __new__(self, data, mask=nomask, dtype=None, fill_value=None, - hardmask=False): - dtype = dtype or data.dtype - _data = np.array(data, dtype=dtype) + hardmask=False, copy=False, subok=True): + _data = np.array(data, copy=copy, subok=subok, dtype=dtype) _data = _data.view(self) _data._hardmask = hardmask if mask is not nomask: diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 8172335a8..34951875d 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -814,7 +814,7 @@ class TestMaskedArrayArithmetic(TestCase): res = count(ott) self.assertTrue(res.dtype.type is np.intp) assert_equal(3, res) - + ott = ott.reshape((2, 2)) res = count(ott) assert_(res.dtype.type is np.intp) @@ -3522,8 +3522,15 @@ class TestMaskedFields(TestCase): assert_equal_records(a[-2]._mask, a._mask[-2]) def test_setitem(self): - # Issue 2403 + # Issue 4866: check that one can set individual items in [record][col] + # and [col][record] order ndtype = np.dtype([('a', float), ('b', int)]) + ma = np.ma.MaskedArray([(1.0, 1), (2.0, 2)], dtype=ndtype) + ma['a'][1] = 3.0 + assert_equal(ma['a'], np.array([1.0, 3.0])) + ma[1]['a'] = 4.0 + assert_equal(ma['a'], np.array([1.0, 4.0])) + # Issue 2403 mdtype = np.dtype([('a', bool), ('b', bool)]) # soft mask control = np.array([(False, True), (True, True)], dtype=mdtype) |