diff options
author | Allan Haldane <allan.haldane@gmail.com> | 2016-02-14 03:01:05 -0500 |
---|---|---|
committer | Allan Haldane <allan.haldane@gmail.com> | 2016-02-26 11:35:33 -0500 |
commit | 6f6f03dc961c15b336242c6600596a8f882ca194 (patch) | |
tree | 08e7c02865bb96abe97c806f22ccc1e736a3e37b /numpy/ma/tests/test_extras.py | |
parent | c303c9b77afbc7fe6f4049683c3ccaabdebe7be3 (diff) | |
download | python-numpy-6f6f03dc961c15b336242c6600596a8f882ca194.tar.gz python-numpy-6f6f03dc961c15b336242c6600596a8f882ca194.tar.bz2 python-numpy-6f6f03dc961c15b336242c6600596a8f882ca194.zip |
TST: Fix some MA tests to avoid looking at the .data attribute
The MaskedArray.data attribute is unreliable for tests because it can
contain arbitraty junk data at masked positions. Instead, all
MaskedArray tests should look at marr.filled(0) to check if we got the
same result.
Diffstat (limited to 'numpy/ma/tests/test_extras.py')
-rw-r--r-- | numpy/ma/tests/test_extras.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/numpy/ma/tests/test_extras.py b/numpy/ma/tests/test_extras.py index 6138d0573..52669cb90 100644 --- a/numpy/ma/tests/test_extras.py +++ b/numpy/ma/tests/test_extras.py @@ -998,7 +998,7 @@ class TestArraySetOps(TestCase): control = array([1, 1, 1, 4], mask=[1, 0, 0, 1]) test = ediff1d(x) assert_equal(test, control) - assert_equal(test.data, control.data) + assert_equal(test.filled(0), control.filled(0)) assert_equal(test.mask, control.mask) def test_ediff1d_tobegin(self): @@ -1007,13 +1007,13 @@ class TestArraySetOps(TestCase): test = ediff1d(x, to_begin=masked) control = array([0, 1, 1, 1, 4], mask=[1, 1, 0, 0, 1]) assert_equal(test, control) - assert_equal(test.data, control.data) + assert_equal(test.filled(0), control.filled(0)) assert_equal(test.mask, control.mask) # test = ediff1d(x, to_begin=[1, 2, 3]) control = array([1, 2, 3, 1, 1, 1, 4], mask=[0, 0, 0, 1, 0, 0, 1]) assert_equal(test, control) - assert_equal(test.data, control.data) + assert_equal(test.filled(0), control.filled(0)) assert_equal(test.mask, control.mask) def test_ediff1d_toend(self): @@ -1022,13 +1022,13 @@ class TestArraySetOps(TestCase): test = ediff1d(x, to_end=masked) control = array([1, 1, 1, 4, 0], mask=[1, 0, 0, 1, 1]) assert_equal(test, control) - assert_equal(test.data, control.data) + assert_equal(test.filled(0), control.filled(0)) assert_equal(test.mask, control.mask) # test = ediff1d(x, to_end=[1, 2, 3]) control = array([1, 1, 1, 4, 1, 2, 3], mask=[1, 0, 0, 1, 0, 0, 0]) assert_equal(test, control) - assert_equal(test.data, control.data) + assert_equal(test.filled(0), control.filled(0)) assert_equal(test.mask, control.mask) def test_ediff1d_tobegin_toend(self): @@ -1037,14 +1037,14 @@ class TestArraySetOps(TestCase): test = ediff1d(x, to_end=masked, to_begin=masked) control = array([0, 1, 1, 1, 4, 0], mask=[1, 1, 0, 0, 1, 1]) assert_equal(test, control) - assert_equal(test.data, control.data) + assert_equal(test.filled(0), control.filled(0)) assert_equal(test.mask, control.mask) # test = ediff1d(x, to_end=[1, 2, 3], to_begin=masked) control = array([0, 1, 1, 1, 4, 1, 2, 3], mask=[1, 1, 0, 0, 1, 0, 0, 0]) assert_equal(test, control) - assert_equal(test.data, control.data) + assert_equal(test.filled(0), control.filled(0)) assert_equal(test.mask, control.mask) def test_ediff1d_ndarray(self): @@ -1054,13 +1054,13 @@ class TestArraySetOps(TestCase): control = array([1, 1, 1, 1], mask=[0, 0, 0, 0]) assert_equal(test, control) self.assertTrue(isinstance(test, MaskedArray)) - assert_equal(test.data, control.data) + assert_equal(test.filled(0), control.filled(0)) assert_equal(test.mask, control.mask) # test = ediff1d(x, to_end=masked, to_begin=masked) control = array([0, 1, 1, 1, 1, 0], mask=[1, 0, 0, 0, 0, 1]) self.assertTrue(isinstance(test, MaskedArray)) - assert_equal(test.data, control.data) + assert_equal(test.filled(0), control.filled(0)) assert_equal(test.mask, control.mask) def test_intersect1d(self): |