Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2747 from mdboom/fix-masked-recarrays-with-objects

cannot access masked array rows with np.object dtype (Fixes #2432)
  • Loading branch information...
commit 686bcfd8a7f8de0886f993fad9fc3608ba476708 2 parents b7b54cd + 457b78f
Nathaniel J. Smith njsmith authored
Showing with 13 additions and 2 deletions.
  1. +1 −2  numpy/ma/core.py
  2. +12 −0 numpy/ma/tests/test_mrecords.py
3  numpy/ma/core.py
View
@@ -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):
12 numpy/ma/tests/test_mrecords.py
View
@@ -502,6 +502,18 @@ def test_addfield(self):
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__":
Please sign in to comment.
Something went wrong with that request. Please try again.