diff options
author | pierregm <pierregm@localhost> | 2009-12-17 21:15:05 +0000 |
---|---|---|
committer | pierregm <pierregm@localhost> | 2009-12-17 21:15:05 +0000 |
commit | f6f1c821fb5bbe83da52e917ccfd66adfd13dc92 (patch) | |
tree | d74f9e7b66ead7e93707dd2db718400f3255f673 /numpy/ma/tests | |
parent | 6938cc09cfa9fa94448132cd48ae4257ccaddc17 (diff) | |
download | numpy-f6f1c821fb5bbe83da52e917ccfd66adfd13dc92.tar.gz |
* added log2
* removed the global np.seterr
* prevented warnings to be emitted with ma.ufuncs
* introduced mvoid to help the iteration/item access of masked structured arrays
Diffstat (limited to 'numpy/ma/tests')
-rw-r--r-- | numpy/ma/tests/test_core.py | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 541c34589..1549ef3c9 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -62,7 +62,6 @@ class TestMaskedArray(TestCase): x = array(0, mask=1) self.failUnless(x.filled().dtype is x._data.dtype) - def test_basic1d(self): "Test of basic array creation and properties in 1 dimension." (x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d @@ -565,6 +564,45 @@ class TestMaskedArray(TestCase): + def test_void0d(self): + "Test creating a mvoid object" + ndtype = [('a', int), ('b', int)] + a = np.array([(1, 2,)], dtype=ndtype)[0] + f = mvoid(a) + assert(isinstance(f, mvoid)) + # + a = masked_array([(1, 2)], mask=[(1, 0)], dtype=ndtype)[0] + assert(isinstance(a, mvoid)) + # + a = masked_array([(1, 2), (1, 2)], mask=[(1, 0), (0, 0)], dtype=ndtype) + f = mvoid(a._data[0], a._mask[0]) + assert(isinstance(f, mvoid)) + + def test_mvoid_getitem(self): + "Test mvoid.__getitem__" + ndtype = [('a', int), ('b', int)] + a = masked_array([(1, 2,), (3, 4)], mask=[(0, 0), (1, 0)], dtype=ndtype) + # w/o mask + f = a[0] + self.failUnless(isinstance(f, np.void)) + assert_equal((f[0], f['a']), (1, 1)) + assert_equal(f['b'], 2) + # w/ mask + f = a[1] + self.failUnless(isinstance(f, mvoid)) + self.failUnless(f[0] is masked) + self.failUnless(f['a'] is masked) + assert_equal(f[1], 4) + + def test_mvoid_iter(self): + "Test iteration on __getitem__" + ndtype = [('a', int), ('b', int)] + a = masked_array([(1, 2,), (3, 4)], mask=[(0, 0), (1, 0)], dtype=ndtype) + # w/o mask + assert_equal(list(a[0]), [1, 2]) + # w/ mask + assert_equal(list(a[1]), [masked, 4]) + #------------------------------------------------------------------------------ |