summaryrefslogtreecommitdiff
path: root/numpy/ma/tests
diff options
context:
space:
mode:
authorpierregm <pierregm@localhost>2009-12-19 20:08:16 +0000
committerpierregm <pierregm@localhost>2009-12-19 20:08:16 +0000
commit55ab10cd15e165dbf129079846adaf3961b527fd (patch)
tree3984d0cf7e1107fb0eed3abdb2dc943032b5113a /numpy/ma/tests
parente700c55fa7ce25128359b843e8913311841dd855 (diff)
downloadnumpy-55ab10cd15e165dbf129079846adaf3961b527fd.tar.gz
* make sure mvoid.tolist returns standard Python objects
Diffstat (limited to 'numpy/ma/tests')
-rw-r--r--numpy/ma/tests/test_core.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
index ba3a23040..700f99ba2 100644
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -396,6 +396,13 @@ class TestMaskedArray(TestCase):
test = cPickle.loads(cPickle.dumps(b))
assert_equal(test, b)
+# def test_pickling_oddity(self):
+# "Test some pickling oddity"
+# import cPickle
+# a = array([{'a':1}, {'b':2}, 3], dtype=object)
+# test = cPickle.loads(cPickle.dumps(a))
+# assert_equal(test, a)
+
def test_single_element_subscript(self):
"Tests single element subscripts of Maskedarrays."
a = array([1, 3, 2])
@@ -2350,6 +2357,19 @@ class TestMaskedArrayMethods(TestCase):
test = a.tolist()
assert_equal(test, [1, None])
+ def test_tolist_specialcase(self):
+ "Test mvoid.tolist: make sure we return a standard Python object"
+ a = array([(0, 1), (2, 3)], dtype=[('a', int), ('b', int)])
+ # w/o mask: each entry is a np.void whose elements are standard Python
+ for entry in a:
+ for item in entry.tolist():
+ assert(not isinstance(item, np.generic))
+ # w/ mask: each entry is a ma.void whose elements should be standard Python
+ a.mask[0] = (0, 1)
+ for entry in a:
+ for item in entry.tolist():
+ assert(not isinstance(item, np.generic))
+
def test_toflex(self):
"Test the conversion to records"