Skip to content

Commit

Permalink
Merge pull request #3447 from efiring/ma_mvoid_len
Browse files Browse the repository at this point in the history
BUG: add __len__ method to ma.mvoid; closes #576
  • Loading branch information
charris committed Jun 17, 2013
2 parents 2a5c2c8 + 216d8cb commit 5e977d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions numpy/ma/core.py
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions numpy/ma/tests/test_core.py
Expand Up @@ -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']))

#------------------------------------------------------------------------------

Expand Down

0 comments on commit 5e977d8

Please sign in to comment.