summaryrefslogtreecommitdiff
path: root/numpy/ma
diff options
context:
space:
mode:
authornjsmith <njs@pobox.com>2012-12-08 11:57:25 -0800
committernjsmith <njs@pobox.com>2012-12-08 11:57:25 -0800
commit686bcfd8a7f8de0886f993fad9fc3608ba476708 (patch)
tree5401fe803ded32f0255c5ef3cb719148dc3f305b /numpy/ma
parentb7b54cdd91305e9334564c7bf388192e35016c77 (diff)
parent457b78f503bbde12c4b2b2ecf25137d7244cca38 (diff)
downloadnumpy-686bcfd8a7f8de0886f993fad9fc3608ba476708.tar.gz
Merge pull request #2747 from mdboom/fix-masked-recarrays-with-objects
cannot access masked array rows with np.object dtype (Fixes #2432)
Diffstat (limited to 'numpy/ma')
-rw-r--r--numpy/ma/core.py3
-rw-r--r--numpy/ma/tests/test_mrecords.py12
2 files changed, 13 insertions, 2 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 7e1a7d89d..dbd619b80 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -5554,8 +5554,7 @@ class mvoid(MaskedArray):
#
def __new__(self, data, mask=nomask, dtype=None, fill_value=None):
dtype = dtype or data.dtype
- _data = ndarray((), dtype=dtype)
- _data[()] = data
+ _data = np.array(data, dtype=dtype)
_data = _data.view(self)
if mask is not nomask:
if isinstance(mask, np.void):
diff --git a/numpy/ma/tests/test_mrecords.py b/numpy/ma/tests/test_mrecords.py
index 1e14042b0..c8d9b0a46 100644
--- a/numpy/ma/tests/test_mrecords.py
+++ b/numpy/ma/tests/test_mrecords.py
@@ -502,6 +502,18 @@ class TestMRecordsImport(TestCase):
assert_equal(mrec.f3, d)
assert_equal(mrec.f3._mask, m)
+
+def test_record_array_with_object_field():
+ """
+ Trac #1839
+ """
+ y = ma.masked_array(
+ [(1,'2'), (3, '4')],
+ mask=[(0, 0), (0, 1)],
+ dtype=[('a', int), ('b', np.object)])
+ x = y[1]
+
+
###############################################################################
#------------------------------------------------------------------------------
if __name__ == "__main__":