diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2007-12-21 08:33:02 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2007-12-21 08:33:02 +0000 |
commit | 11c95e35e85166b808ea24d321f86a7bc4a0dcab (patch) | |
tree | 272101e8bf9fee1e3ceb89efe36d03c1b96e0b8d /numpy/ma/tests | |
parent | c9fe4c3bf9eb239d13173a55b530c1349e22835d (diff) | |
download | numpy-11c95e35e85166b808ea24d321f86a7bc4a0dcab.tar.gz |
Fix unit tests. Prevent nomask from being copied.
Diffstat (limited to 'numpy/ma/tests')
-rw-r--r-- | numpy/ma/tests/test_core.py | 15 | ||||
-rw-r--r-- | numpy/ma/tests/test_old_ma.py | 11 |
2 files changed, 16 insertions, 10 deletions
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index d8caaaf6c..48e8682ce 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -29,6 +29,18 @@ pi = numpy.pi from test_old_ma import * +class TestNoMask(NumpyTestCase): + def test_no_inplace(self): + x = nomask + def iadd(x): + x += 1 + self.failUnlessRaises(ValueError,iadd,x) + + def test_no_copy(self): + x = nomask + y = x.copy() + assert x is y + #.............................................................................. class TestMA(NumpyTestCase): "Base test class for MaskedArrays." @@ -1304,10 +1316,9 @@ class TestArrayMethods(NumpyTestCase): assert(data.squeeze() is masked) def check_putmask(self): - x = numpy.arange(6)+1 + x = arange(6)+1 mx = array(x, mask=[0,0,0,1,1,1]) mask = [0,0,1,0,0,1] - # w/o mask, w/o masked values xx = x.copy() putmask(xx, mask, 99) diff --git a/numpy/ma/tests/test_old_ma.py b/numpy/ma/tests/test_old_ma.py index 41be92011..c2da8b3f3 100644 --- a/numpy/ma/tests/test_old_ma.py +++ b/numpy/ma/tests/test_old_ma.py @@ -304,10 +304,8 @@ class TestMa(NumpyTestCase): (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d m = [1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1] i = numpy.nonzero(m)[0] - putmask(xm, m, z) - assert all(take(xm, i, axis=0) == z) put(ym, i, zm) - assert take(ym, i, axis=0) == zm + assert all(take(ym, i, axis=0) == zm) def check_testOddFeatures(self): "Test of other odd features" @@ -584,11 +582,8 @@ class TestMa(NumpyTestCase): self.assertEqual(1, int(array([[[1]]]))) self.assertEqual(1.0, float(array([[1]]))) self.failUnlessRaises(ValueError, float, array([1,1])) - self.failUnlessRaises(MAError, float, array([1],mask=[1])) - self.failUnless(bool(array([0,1]))) - self.failUnless(bool(array([0,0],mask=[0,1]))) - self.failIf(bool(array([0,0]))) - self.failIf(bool(array([0,0],mask=[0,0]))) + self.failUnlessRaises(ValueError, bool, array([0,1])) + self.failUnlessRaises(ValueError, bool, array([0,0],mask=[0,1])) def check_testScalarArithmetic(self): xm = array(0, mask=1) |