diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 4c574b3bed74..fc086e5b7d7b 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -5643,6 +5643,9 @@ def __iter__(self): else: yield d + def __len__(self): + return self._data.__len__() + def filled(self, fill_value=None): """ Return a copy with masked fields filled with a given value. diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 523eb77fcb71..3b25090ab1ea 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -3527,6 +3527,10 @@ def test_setitem(self): a[0]['a'] = 2 assert_equal(a.mask, control) + def test_element_len(self): + # check that len() works for mvoid (Github issue #576) + for rec in self.data['base']: + assert_equal(len(rec), len(self.data['ddtype'])) #------------------------------------------------------------------------------