summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorEric Firing <efiring@hawaii.edu>2013-06-15 15:31:52 -1000
committerEric Firing <efiring@hawaii.edu>2013-06-16 09:31:53 -1000
commit216d8cbc46f808eeff1942b3a607afca427125f2 (patch)
tree343b7b595c4fa467d7fd3f09dd606a74f494c5f6 /numpy
parent2a5c2c8227b600654f31ed346c73cce77bef554d (diff)
downloadnumpy-216d8cbc46f808eeff1942b3a607afca427125f2.tar.gz
BUG: add __len__ method to ma.mvoid; closes #576
Diffstat (limited to 'numpy')
-rw-r--r--numpy/ma/core.py3
-rw-r--r--numpy/ma/tests/test_core.py4
2 files changed, 7 insertions, 0 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 4c574b3be..fc086e5b7 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -5643,6 +5643,9 @@ class mvoid(MaskedArray):
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 523eb77fc..3b25090ab 100644
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -3527,6 +3527,10 @@ class TestMaskedFields(TestCase):
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']))
#------------------------------------------------------------------------------