summaryrefslogtreecommitdiff
path: root/numpy/ma/tests/test_extras.py
diff options
context:
space:
mode:
authorpierregm <pierregm@localhost>2009-04-13 11:24:40 +0000
committerpierregm <pierregm@localhost>2009-04-13 11:24:40 +0000
commit430647c0dbdde130f0747c1fa2b1939d33e8f9b6 (patch)
tree1f169859fae972a87927b907fa87b3eaeb558333 /numpy/ma/tests/test_extras.py
parentd673c50ccfe30f0b97de2d853e20fdc191a3fe30 (diff)
downloadnumpy-430647c0dbdde130f0747c1fa2b1939d33e8f9b6.tar.gz
* fixed notmasked_edges when no data are masked
Diffstat (limited to 'numpy/ma/tests/test_extras.py')
-rw-r--r--numpy/ma/tests/test_extras.py52
1 files changed, 38 insertions, 14 deletions
diff --git a/numpy/ma/tests/test_extras.py b/numpy/ma/tests/test_extras.py
index 5ae7bd72c..3c6de62be 100644
--- a/numpy/ma/tests/test_extras.py
+++ b/numpy/ma/tests/test_extras.py
@@ -183,24 +183,45 @@ class TestConcatenator(TestCase):
assert_array_equal(d[5:,:],b_2)
assert_array_equal(d.mask, np.r_[m_1,m_2])
+
+
class TestNotMasked(TestCase):
"Tests notmasked_edges and notmasked_contiguous."
def test_edges(self):
"Tests unmasked_edges"
- a = masked_array(np.arange(24).reshape(3,8),
- mask=[[0,0,0,0,1,1,1,0],
- [1,1,1,1,1,1,1,1],
- [0,0,0,0,0,0,1,0],])
- #
- assert_equal(notmasked_edges(a, None), [0,23])
- #
- tmp = notmasked_edges(a, 0)
- assert_equal(tmp[0], (array([0,0,0,0,2,2,0]), array([0,1,2,3,4,5,7])))
- assert_equal(tmp[1], (array([2,2,2,2,2,2,2]), array([0,1,2,3,4,5,7])))
- #
- tmp = notmasked_edges(a, 1)
- assert_equal(tmp[0], (array([0,2,]), array([0,0])))
- assert_equal(tmp[1], (array([0,2,]), array([7,7])))
+ data = masked_array(np.arange(25).reshape(5, 5),
+ mask=[[0, 0, 1, 0, 0],
+ [0, 0, 0, 1, 1],
+ [1, 1, 0, 0, 0],
+ [0, 0, 0, 0, 0],
+ [1, 1, 1, 0, 0]],)
+ test = notmasked_edges(data, None)
+ assert_equal(test, [0, 24])
+ test = notmasked_edges(data, 0)
+ assert_equal(test[0], [(0, 0, 1, 0, 0), (0, 1, 2, 3, 4)])
+ assert_equal(test[1], [(3, 3, 3, 4, 4), (0, 1, 2, 3, 4)])
+ test = notmasked_edges(data, 1)
+ assert_equal(test[0], [(0, 1, 2, 3, 4), (0, 0, 2, 0, 3)])
+ assert_equal(test[1], [(0, 1, 2, 3, 4), (4, 2, 4, 4, 4)])
+ #
+ test = notmasked_edges(data.data, None)
+ assert_equal(test, [0, -1])
+ test = notmasked_edges(data.data, 0)
+ assert_equal(test[0], [(0, 0, 0, 0, 0), (0, 1, 2, 3, 4)])
+ assert_equal(test[1], [(4, 4, 4, 4, 4), (0, 1, 2, 3, 4)])
+ test = notmasked_edges(data.data, -1)
+ assert_equal(test[0], [(0, 1, 2, 3, 4), (0, 0, 0, 0, 0)])
+ assert_equal(test[1], [(0, 1, 2, 3, 4), (4, 4, 4, 4, 4)])
+ #
+ data[-2] = masked
+ test = notmasked_edges(data, 0)
+ assert_equal(test[0], [(0, 0, 1, 0, 0), (0, 1, 2, 3, 4)])
+ assert_equal(test[1], [(1, 1, 2, 4, 4), (0, 1, 2, 3, 4)])
+ test = notmasked_edges(data, -1)
+ assert_equal(test[0], [(0, 1, 2, 4), (0, 0, 2, 3)])
+ assert_equal(test[1], [(0, 1, 2, 4), (4, 2, 4, 4)])
+
+
def test_contiguous(self):
"Tests notmasked_contiguous"
@@ -225,6 +246,9 @@ class TestNotMasked(TestCase):
assert_equal(tmp[2][-1], slice(7,7,None))
assert_equal(tmp[2][-2], slice(0,5,None))
+
+
+
class Test2DFunctions(TestCase):
"Tests 2D functions"
def test_compress2d(self):