diff options
author | pierregm <pierregm@localhost> | 2009-01-08 20:02:29 +0000 |
---|---|---|
committer | pierregm <pierregm@localhost> | 2009-01-08 20:02:29 +0000 |
commit | a5da87c6254f183dc068d912dde9fd00341d926f (patch) | |
tree | 2f670af8704ef7d67abacbb6a0e0f7ac3630115d /numpy/ma/tests | |
parent | 99f428eeb52ce65e79defff4306aebc601ee1c42 (diff) | |
download | numpy-a5da87c6254f183dc068d912dde9fd00341d926f.tar.gz |
* Add __eq__ and __ne__ for support of flexible arrays.
* Fixed .filled for nested structures
Diffstat (limited to 'numpy/ma/tests')
-rw-r--r-- | numpy/ma/tests/test_core.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index dbb56319f..9ac4342e6 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -474,6 +474,16 @@ class TestMaskedArray(TestCase): np.array([(1, '1', 1.)], dtype=flexi.dtype)) + def test_filled_w_nested_dtype(self): + "Test filled w/ nested dtype" + ndtype = [('A', int), ('B', [('BA', int), ('BB', int)])] + a = array([(1, (1, 1)), (2, (2, 2))], + mask=[(0, (1, 0)), (0, (0, 1))], dtype=ndtype) + test = a.filled(0) + control = np.array([(1, (0, 1)), (2, (2, 0))], dtype=ndtype) + assert_equal(test, control) + + def test_optinfo_propagation(self): "Checks that _optinfo dictionary isn't back-propagated" x = array([1,2,3,], dtype=float) @@ -884,6 +894,40 @@ class TestMaskedArrayArithmetic(TestCase): self.failUnless(output[0] is masked) + def test_eq_on_structured(self): + "Test the equality of structured arrays" + ndtype = [('A', int), ('B', int)] + a = array([(1, 1), (2, 2)], mask=[(0, 1), (0, 0)], dtype=ndtype) + test = (a == a) + assert_equal(test, [True, True]) + assert_equal(test.mask, [False, False]) + b = array([(1, 1), (2, 2)], mask=[(1, 0), (0, 0)], dtype=ndtype) + test = (a == b) + assert_equal(test, [False, True]) + assert_equal(test.mask, [True, False]) + b = array([(1, 1), (2, 2)], mask=[(0, 1), (1, 0)], dtype=ndtype) + test = (a == b) + assert_equal(test, [True, False]) + assert_equal(test.mask, [False, False]) + + + def test_ne_on_structured(self): + "Test the equality of structured arrays" + ndtype = [('A', int), ('B', int)] + a = array([(1, 1), (2, 2)], mask=[(0, 1), (0, 0)], dtype=ndtype) + test = (a != a) + assert_equal(test, [False, False]) + assert_equal(test.mask, [False, False]) + b = array([(1, 1), (2, 2)], mask=[(1, 0), (0, 0)], dtype=ndtype) + test = (a != b) + assert_equal(test, [True, False]) + assert_equal(test.mask, [True, False]) + b = array([(1, 1), (2, 2)], mask=[(0, 1), (1, 0)], dtype=ndtype) + test = (a != b) + assert_equal(test, [False, True]) + assert_equal(test.mask, [False, False]) + + #------------------------------------------------------------------------------ class TestMaskedArrayAttributes(TestCase): |