[Numpy-svn] r5880 - trunk/numpy/ma/tests

numpy-svn@scip... numpy-svn@scip...
Mon Sep 29 15:25:01 CDT 2008


Author: pierregm
Date: 2008-09-29 15:24:56 -0500 (Mon, 29 Sep 2008)
New Revision: 5880

Modified:
   trunk/numpy/ma/tests/test_core.py
   trunk/numpy/ma/tests/test_extras.py
   trunk/numpy/ma/tests/test_mrecords.py
   trunk/numpy/ma/tests/test_subclassing.py
Log:
replaced assert with self.failUnless

Modified: trunk/numpy/ma/tests/test_core.py
===================================================================
--- trunk/numpy/ma/tests/test_core.py	2008-09-29 20:24:29 UTC (rev 5879)
+++ trunk/numpy/ma/tests/test_core.py	2008-09-29 20:24:56 UTC (rev 5880)
@@ -60,15 +60,15 @@
         x = masked_array(0, mask=False)
         assert_equal(str(x), '0')
         x = array(0, mask=1)
-        assert(x.filled().dtype is x._data.dtype)
+        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
-        assert(not isMaskedArray(x))
-        assert(isMaskedArray(xm))
-        assert((xm-ym).filled(0).any())
+        self.failUnless(not isMaskedArray(x))
+        self.failUnless(isMaskedArray(xm))
+        self.failUnless((xm-ym).filled(0).any())
         fail_if_equal(xm.mask.astype(int_), ym.mask.astype(int_))
         s = x.shape
         assert_equal(np.shape(xm), s)
@@ -92,8 +92,8 @@
             ym.shape = s
             xf.shape = s
             #
-            assert(not isMaskedArray(x))
-            assert(isMaskedArray(xm))
+            self.failUnless(not isMaskedArray(x))
+            self.failUnless(isMaskedArray(xm))
             assert_equal(shape(xm), s)
             assert_equal(xm.shape, s)
             assert_equal( xm.size , reduce(lambda x,y:x*y, s))
@@ -177,7 +177,7 @@
         x.mask = nomask
         data = array((x,x[::-1]))
         assert_equal(data, [[0,1,2,3,4],[4,3,2,1,0]])
-        assert(data.mask is nomask)
+        self.failUnless(data.mask is nomask)
 
     def test_asarray(self):
         (x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d
@@ -200,8 +200,8 @@
         "Test of masked element"
         x = arange(6)
         x[1] = masked
-        assert(str(masked) ==  '--')
-        assert(x[1] is masked)
+        self.failUnless(str(masked) ==  '--')
+        self.failUnless(x[1] is masked)
         assert_equal(filled(x[1], 0), 0)
         # don't know why these should raise an exception...
         #self.failUnlessRaises(Exception, lambda x,y: x+y, masked, masked)
@@ -215,12 +215,12 @@
         x = (1,2,3,4,5)
         a[0] = x
         assert_equal(a[0], x)
-        assert(a[0] is x)
+        self.failUnless(a[0] is x)
         #
         import datetime
         dt = datetime.datetime.now()
         a[0] = dt
-        assert(a[0] is dt)
+        self.failUnless(a[0] is dt)
 
 
     def test_indexing(self):
@@ -279,39 +279,39 @@
         n = [0,0,1,0,0]
         m = make_mask(n)
         m2 = make_mask(m)
-        assert(m is m2)
+        self.failUnless(m is m2)
         m3 = make_mask(m, copy=1)
-        assert(m is not m3)
+        self.failUnless(m is not m3)
 
         warnings.simplefilter('ignore', DeprecationWarning)
         x1 = np.arange(5)
         y1 = array(x1, mask=m)
-        #assert( y1._data is x1)
+        #self.failUnless( y1._data is x1)
         assert_equal(y1._data.__array_interface__, x1.__array_interface__)
-        assert( allequal(x1,y1.raw_data()))
-        #assert( y1.mask is m)
+        self.failUnless( allequal(x1,y1.raw_data()))
+        #self.failUnless( y1.mask is m)
         assert_equal(y1._mask.__array_interface__, m.__array_interface__)
         warnings.simplefilter('default', DeprecationWarning)
 
         y1a = array(y1)
-        #assert( y1a.raw_data() is y1.raw_data())
-        assert( y1a._data.__array_interface__ == y1._data.__array_interface__)
-        assert( y1a.mask is y1.mask)
+        #self.failUnless( y1a.raw_data() is y1.raw_data())
+        self.failUnless( y1a._data.__array_interface__ == y1._data.__array_interface__)
+        self.failUnless( y1a.mask is y1.mask)
 
         y2 = array(x1, mask=m)
-        #assert( y2.raw_data() is x1)
-        assert (y2._data.__array_interface__ == x1.__array_interface__)
-        #assert( y2.mask is m)
-        assert (y2._mask.__array_interface__ == m.__array_interface__)
-        assert( y2[2] is masked)
+        #self.failUnless( y2.raw_data() is x1)
+        self.failUnless(y2._data.__array_interface__ == x1.__array_interface__)
+        #self.failUnless( y2.mask is m)
+        self.failUnless(y2._mask.__array_interface__ == m.__array_interface__)
+        self.failUnless( y2[2] is masked)
         y2[2] = 9
-        assert( y2[2] is not masked)
-        #assert( y2.mask is not m)
-        assert (y2._mask.__array_interface__ != m.__array_interface__)
-        assert( allequal(y2.mask, 0))
+        self.failUnless( y2[2] is not masked)
+        #self.failUnless( y2.mask is not m)
+        self.failUnless(y2._mask.__array_interface__ != m.__array_interface__)
+        self.failUnless( allequal(y2.mask, 0))
 
         y3 = array(x1*1.0, mask=m)
-        assert(filled(y3).dtype is (x1*1.0).dtype)
+        self.failUnless(filled(y3).dtype is (x1*1.0).dtype)
 
         x4 = arange(4)
         x4[2] = masked
@@ -374,7 +374,7 @@
         a_pickled = cPickle.loads(a.dumps())
         assert_equal(a_pickled._mask, a._mask)
         assert_equal(a_pickled, a)
-        assert(isinstance(a_pickled._data,np.matrix))
+        self.failUnless(isinstance(a_pickled._data,np.matrix))
 
 
     def test_single_element_subscript(self):
@@ -401,7 +401,7 @@
         a = array([1,2,3],mask=[1,0,0])
         self.assertRaises(TypeError, lambda:float(a))
         assert_equal(float(a[-1]), 3.)
-        assert(np.isnan(float(a[0])))
+        self.failUnless(np.isnan(float(a[0])))
         self.assertRaises(TypeError, int, a)
         assert_equal(int(a[-1]), 3)
         self.assertRaises(MAError, lambda:int(a[0]))
@@ -575,11 +575,11 @@
         "Tests some scalar arithmetics on MaskedArrays."
         # Masked singleton should remain masked no matter what
         xm = array(0, mask=1)
-        assert((1/array(0)).mask)
-        assert((1 + xm).mask)
-        assert((-xm).mask)
-        assert(maximum(xm, xm).mask)
-        assert(minimum(xm, xm).mask)
+        self.failUnless((1/array(0)).mask)
+        self.failUnless((1 + xm).mask)
+        self.failUnless((-xm).mask)
+        self.failUnless(maximum(xm, xm).mask)
+        self.failUnless(minimum(xm, xm).mask)
 
     def test_arithmetic_with_masked_singleton(self):
         "Checks that there's no collapsing to masked"
@@ -633,7 +633,7 @@
     def test_count_func (self):
         "Tests count"
         ott = array([0.,1.,2.,3.], mask=[1,0,0,0])
-        assert( isinstance(count(ott), int))
+        self.failUnless( isinstance(count(ott), int))
         assert_equal(3, count(ott))
         assert_equal(1, count(1))
         assert_equal(0, array(1,mask=[1]))
@@ -670,19 +670,19 @@
     def test_minimummaximum_func(self):
         a = np.ones((2,2))
         aminimum = minimum(a,a)
-        assert(isinstance(aminimum, MaskedArray))
+        self.failUnless(isinstance(aminimum, MaskedArray))
         assert_equal(aminimum, np.minimum(a,a))
         #
         aminimum = minimum.outer(a,a)
-        assert(isinstance(aminimum, MaskedArray))
+        self.failUnless(isinstance(aminimum, MaskedArray))
         assert_equal(aminimum, np.minimum.outer(a,a))
         #
         amaximum = maximum(a,a)
-        assert(isinstance(amaximum, MaskedArray))
+        self.failUnless(isinstance(amaximum, MaskedArray))
         assert_equal(amaximum, np.maximum(a,a))
         #
         amaximum = maximum.outer(a,a)
-        assert(isinstance(amaximum, MaskedArray))
+        self.failUnless(isinstance(amaximum, MaskedArray))
         assert_equal(amaximum, np.maximum.outer(a,a))
 
     def test_minmax_funcs_with_output(self):
@@ -697,11 +697,11 @@
             # Use the np version
             nout = np.empty((4,), dtype=int)
             result = npfunc(xm,axis=0,out=nout)
-            assert(result is nout)
+            self.failUnless(result is nout)
             # Use the ma version
             nout.fill(-999)
             result = mafunc(xm,axis=0,out=nout)
-            assert(result is nout)
+            self.failUnless(result is nout)
 
 
     def test_minmax_methods(self):
@@ -709,22 +709,22 @@
         (_, _, _, _, _, xm, _, _, _, _) = self.d
         xm.shape = (xm.size,)
         assert_equal(xm.max(), 10)
-        assert(xm[0].max() is masked)
-        assert(xm[0].max(0) is masked)
-        assert(xm[0].max(-1) is masked)
+        self.failUnless(xm[0].max() is masked)
+        self.failUnless(xm[0].max(0) is masked)
+        self.failUnless(xm[0].max(-1) is masked)
         assert_equal(xm.min(), -10.)
-        assert(xm[0].min() is masked)
-        assert(xm[0].min(0) is masked)
-        assert(xm[0].min(-1) is masked)
+        self.failUnless(xm[0].min() is masked)
+        self.failUnless(xm[0].min(0) is masked)
+        self.failUnless(xm[0].min(-1) is masked)
         assert_equal(xm.ptp(), 20.)
-        assert(xm[0].ptp() is masked)
-        assert(xm[0].ptp(0) is masked)
-        assert(xm[0].ptp(-1) is masked)
+        self.failUnless(xm[0].ptp() is masked)
+        self.failUnless(xm[0].ptp(0) is masked)
+        self.failUnless(xm[0].ptp(-1) is masked)
         #
         x = array([1,2,3], mask=True)
-        assert(x.min() is masked)
-        assert(x.max() is masked)
-        assert(x.ptp() is masked)
+        self.failUnless(x.min() is masked)
+        self.failUnless(x.max() is masked)
+        self.failUnless(x.ptp() is masked)
     #........................
     def test_addsumprod (self):
         "Tests add, sum, product."
@@ -797,13 +797,13 @@
             output.fill(-9999)
             result = npfunc(xm, axis=0,out=output)
             # ... the result should be the given output
-            assert(result is output)
+            self.failUnless(result is output)
             assert_equal(result, xmmeth(axis=0, out=output))
             #
             output = empty(4, dtype=int)
             result = xmmeth(axis=0, out=output)
-            assert(result is output)
-            assert(output[0] is masked)
+            self.failUnless(result is output)
+            self.failUnless(output[0] is masked)
 
 #------------------------------------------------------------------------------
 
@@ -837,8 +837,8 @@
         assert_equal(xs._data, [0,10,2,3,40])
         #assert_equal(xh.mask.ctypes._data, m.ctypes._data)
         assert_equal(xs.mask, [0,0,0,1,0])
-        assert(xh._hardmask)
-        assert(not xs._hardmask)
+        self.failUnless(xh._hardmask)
+        self.failUnless(not xs._hardmask)
         xh[1:4] = [10,20,30]
         xs[1:4] = [10,20,30]
         assert_equal(xh._data, [0,10,20,3,4])
@@ -931,39 +931,39 @@
         ndtype = [('a',int),('b',float),('c',"|S3")]
         # A check on a list should return a single record
         fval = _check_fill_value([-999,-999.9,"???"], ndtype)
-        assert(isinstance(fval,ndarray))
+        self.failUnless(isinstance(fval,ndarray))
         assert_equal(fval.item(), [-999,-999.9,"???"])
         # A check on Non should output the defaults
         fval = _check_fill_value(None, ndtype)
-        assert(isinstance(fval,ndarray))
+        self.failUnless(isinstance(fval,ndarray))
         assert_equal(fval.item(), [default_fill_value(0),
                                    default_fill_value(0.),
                                    default_fill_value("0")])
         #.....Using a flexible type as fill_value should work
         fill_val = np.array((-999,-999.9,"???"),dtype=ndtype)
         fval = _check_fill_value(fill_val, ndtype)
-        assert(isinstance(fval,ndarray))
+        self.failUnless(isinstance(fval,ndarray))
         assert_equal(fval.item(), [-999,-999.9,"???"])
         #.....Using a flexible type w/ a different type shouldn't matter
         fill_val = np.array((-999,-999.9,"???"),
                             dtype=[("A",int),("B",float),("C","|S3")])
         fval = _check_fill_value(fill_val, ndtype)
-        assert(isinstance(fval,ndarray))
+        self.failUnless(isinstance(fval,ndarray))
         assert_equal(fval.item(), [-999,-999.9,"???"])
         #.....Using an object-array shouldn't matter either
         fill_value =  np.array((-999,-999.9,"???"), dtype=object)
         fval = _check_fill_value(fill_val, ndtype)
-        assert(isinstance(fval,ndarray))
+        self.failUnless(isinstance(fval,ndarray))
         assert_equal(fval.item(), [-999,-999.9,"???"])
         #
         fill_value =  np.array((-999,-999.9,"???"))
         fval = _check_fill_value(fill_val, ndtype)
-        assert(isinstance(fval,ndarray))
+        self.failUnless(isinstance(fval,ndarray))
         assert_equal(fval.item(), [-999,-999.9,"???"])
         #.....One-field-only flexible type should work as well
         ndtype = [("a",int)]
         fval = _check_fill_value(-999, ndtype)
-        assert(isinstance(fval,ndarray))
+        self.failUnless(isinstance(fval,ndarray))
         assert_equal(fval.item(), (-999,))
 
 
@@ -1087,8 +1087,8 @@
     def test_reduce(self):
         "Tests reduce on MaskedArrays."
         a = self.d[0]
-        assert(not alltrue(a,axis=0))
-        assert(sometrue(a,axis=0))
+        self.failUnless(not alltrue(a,axis=0))
+        self.failUnless(sometrue(a,axis=0))
         assert_equal(sum(a[:3],axis=0), 0)
         assert_equal(product(a,axis=0), 0)
         assert_equal(add.reduce(a), pi)
@@ -1101,8 +1101,8 @@
         assert_equal(amask.min(), 5)
         assert_equal(amask.max(0), a.max(0))
         assert_equal(amask.min(0), [5,6,7,8])
-        assert(amask.max(1)[0].mask)
-        assert(amask.min(1)[0].mask)
+        self.failUnless(amask.max(1)[0].mask)
+        self.failUnless(amask.min(1)[0].mask)
 
 
 #------------------------------------------------------------------------------
@@ -1355,18 +1355,18 @@
         store = empty(1, dtype=bool)
         full = array([1,2,3], mask=True)
         #
-        assert(full.all() is masked)
+        self.failUnless(full.all() is masked)
         full.all(out=store)
-        assert(store)
-        assert(store._mask, True)
-        assert(store is not masked)
+        self.failUnless(store)
+        self.failUnless(store._mask, True)
+        self.failUnless(store is not masked)
         #
         store = empty(1, dtype=bool)
-        assert(full.any() is masked)
+        self.failUnless(full.any() is masked)
         full.any(out=store)
-        assert(not store)
-        assert(store._mask, True)
-        assert(store is not masked)
+        self.failUnless(not store)
+        self.failUnless(store._mask, True)
+        self.failUnless(store is not masked)
 
 
     def test_argmax_argmin(self):
@@ -1454,7 +1454,7 @@
         a = array(np.matrix([1,2,3,4]), mask=[0,0,0,0])
         b = a.compressed()
         assert_equal(b,a)
-        assert(isinstance(b,np.matrix))
+        self.failUnless(isinstance(b,np.matrix))
         a[0,0] = masked
         b = a.compressed()
         assert_equal(b, [[2,3,4]])
@@ -1482,12 +1482,12 @@
         n = [0,0,0,1,1]
         m = make_mask(n)
         x = array(d, mask = m)
-        assert( x[3] is masked)
-        assert( x[4] is masked)
+        self.failUnless( x[3] is masked)
+        self.failUnless( x[4] is masked)
         x[[1,4]] = [10,40]
-#        assert( x.mask is not m)
-        assert( x[3] is masked)
-        assert( x[4] is not masked)
+#        self.failUnless( x.mask is not m)
+        self.failUnless( x[3] is masked)
+        self.failUnless( x[4] is not masked)
         assert_equal(x, [0,10,2,-1,40])
         #
         x = masked_array(arange(10), mask=[1,0,0,0,0]*2)
@@ -1607,7 +1607,7 @@
         #
         x = [1,4,2,3]
         sortedx = sort(x)
-        assert(not isinstance(sorted, MaskedArray))
+        self.failUnless(not isinstance(sorted, MaskedArray))
         #
         x = array([0,1,-1,-2,2], mask=nomask, dtype=np.int8)
         sortedx = sort(x, endwith=False)
@@ -1667,7 +1667,7 @@
         assert_equal(data.squeeze(), [1,2,3])
         assert_equal(data.squeeze()._mask, [1,1,1])
         data = masked_array([[1]], mask=True)
-        assert(data.squeeze() is masked)
+        self.failUnless(data.squeeze() is masked)
 
 
     def test_swapaxes(self):
@@ -1714,8 +1714,8 @@
         x = array(np.arange(12))
         x[[1,-2]] = masked
         xlist = x.tolist()
-        assert(xlist[1] is None)
-        assert(xlist[-2] is None)
+        self.failUnless(xlist[1] is None)
+        self.failUnless(xlist[-2] is None)
         #
         x.shape = (3,4)
         xlist = x.tolist()
@@ -1830,12 +1830,12 @@
             output.fill(-9999)
             result = npfunc(xm, axis=0,out=output)
             # ... the result should be the given output
-            assert(result is output)
+            self.failUnless(result is output)
             assert_equal(result, xmmeth(axis=0, out=output))
             #
             output = empty((3,4), dtype=int)
             result = xmmeth(axis=0, out=output)
-            assert(result is output)
+            self.failUnless(result is output)
 
 
     def test_ptp(self):
@@ -1890,31 +1890,31 @@
         x = array(arange(10), mask=True)
         for methodname in ('var', 'std'):
             method = getattr(x,methodname)
-            assert(method() is masked)
-            assert(method(0) is masked)
-            assert(method(-1) is masked)
+            self.failUnless(method() is masked)
+            self.failUnless(method(0) is masked)
+            self.failUnless(method(-1) is masked)
             # Using a masked array as explicit output
             _ = method(out=mout)
-            assert(mout is not masked)
+            self.failUnless(mout is not masked)
             assert_equal(mout.mask, True)
             # Using a ndarray as explicit output
             _ = method(out=nout)
-            assert(np.isnan(nout))
+            self.failUnless(np.isnan(nout))
         #
         x = array(arange(10), mask=True)
         x[-1] = 9
         for methodname in ('var', 'std'):
             method = getattr(x,methodname)
-            assert(method(ddof=1) is masked)
-            assert(method(0, ddof=1) is masked)
-            assert(method(-1, ddof=1) is masked)
+            self.failUnless(method(ddof=1) is masked)
+            self.failUnless(method(0, ddof=1) is masked)
+            self.failUnless(method(-1, ddof=1) is masked)
             # Using a masked array as explicit output
             _ = method(out=mout, ddof=1)
-            assert(mout is not masked)
+            self.failUnless(mout is not masked)
             assert_equal(mout.mask, True)
             # Using a ndarray as explicit output
             _ = method(out=nout, ddof=1)
-            assert(np.isnan(nout))
+            self.failUnless(np.isnan(nout))
 
 #------------------------------------------------------------------------------
 
@@ -2032,7 +2032,7 @@
         else:
             raise AssertionError("Should have failed...")
         test = masked_equal(a,1)
-        assert(test.mask, [0,1,0,0,0,0,0,0,0,0])
+        assert_equal(test.mask, [0,1,0,0,0,0,0,0,0,0])
 
 
     def test_masked_otherfunctions(self):
@@ -2078,24 +2078,24 @@
         output.fill(-9999)
         result = np.round(xm, decimals=2,out=output)
         # ... the result should be the given output
-        assert(result is output)
+        self.failUnless(result is output)
         assert_equal(result, xm.round(decimals=2, out=output))
         #
         output = empty((3,4), dtype=float)
         result = xm.round(decimals=2, out=output)
-        assert(result is output)
+        self.failUnless(result is output)
 
 
     def test_identity(self):
         a = identity(5)
-        assert(isinstance(a, MaskedArray))
+        self.failUnless(isinstance(a, MaskedArray))
         assert_equal(a, np.identity(5))
 
 
     def test_power(self):
         x = -1.1
         assert_almost_equal(power(x,2.), 1.21)
-        assert(power(x,masked) is masked)
+        self.failUnless(power(x,masked) is masked)
         x = array([-1.1,-1.1,1.1,1.1,0.])
         b = array([0.5,2.,0.5,2.,-1.], mask=[0,0,0,0,1])
         y = power(x,b)
@@ -2228,7 +2228,7 @@
         store = empty(4, dtype=int)
         chosen = choose([2, 3, 1, 0], choices, out=store)
         assert_equal(store, array([20, 31, 12, 3]))
-        assert(store is chosen)
+        self.failUnless(store is chosen)
         # Check with some masked indices + out
         store = empty(4, dtype=int)
         indices_ = array([2, 3, 1, 0], mask=[1,0,0,1])
@@ -2250,25 +2250,25 @@
         # Try the default
         b = a.reshape((5,2))
         assert_equal(b.shape, (5,2))
-        assert(b.flags['C'])
+        self.failUnless(b.flags['C'])
         # Try w/ arguments as list instead of tuple
         b = a.reshape(5,2)
         assert_equal(b.shape, (5,2))
-        assert(b.flags['C'])
+        self.failUnless(b.flags['C'])
         # Try w/ order
         b = a.reshape((5,2), order='F')
         assert_equal(b.shape, (5,2))
-        assert(b.flags['F'])
+        self.failUnless(b.flags['F'])
         # Try w/ order
         b = a.reshape(5,2, order='F')
         assert_equal(b.shape, (5,2))
-        assert(b.flags['F'])
+        self.failUnless(b.flags['F'])
         #
         c = np.reshape(a, (2,5))
-        assert(isinstance(c, MaskedArray))
+        self.failUnless(isinstance(c, MaskedArray))
         assert_equal(c.shape, (2,5))
-        assert(c[0,0] is masked)
-        assert(c.flags['C'])
+        self.failUnless(c[0,0] is masked)
+        self.failUnless(c.flags['C'])
 
 #------------------------------------------------------------------------------
 
@@ -2380,7 +2380,7 @@
         #
         test = a.view((float,2), np.matrix)
         assert_equal(test, data)
-        assert(isinstance(test, np.matrix))
+        self.failUnless(isinstance(test, np.matrix))
     #
     def test_getitem(self):
         ndtype = [('a',float), ('b',float)]
@@ -2389,13 +2389,13 @@
                               [1,0,0,0,0,0,0,0,1,0]),
                           dtype=[('a',bool),('b',bool)])
         # No mask
-        assert(isinstance(a[1], np.void))
+        self.failUnless(isinstance(a[1], np.void))
         # One element masked
-        assert(isinstance(a[0], MaskedArray))
+        self.failUnless(isinstance(a[0], MaskedArray))
         assert_equal_records(a[0]._data, a._data[0])
         assert_equal_records(a[0]._mask, a._mask[0])
         # All element masked
-        assert(isinstance(a[-2], MaskedArray))
+        self.failUnless(isinstance(a[-2], MaskedArray))
         assert_equal_records(a[-2]._data, a._data[-2])
         assert_equal_records(a[-2]._mask, a._mask[-2])
 

Modified: trunk/numpy/ma/tests/test_extras.py
===================================================================
--- trunk/numpy/ma/tests/test_extras.py	2008-09-29 20:24:29 UTC (rev 5879)
+++ trunk/numpy/ma/tests/test_extras.py	2008-09-29 20:24:56 UTC (rev 5880)
@@ -26,7 +26,7 @@
         assert_equal(2.0, average(ott, weights=[1., 1., 2., 1.]))
         result, wts = average(ott, weights=[1.,1.,2.,1.], returned=1)
         assert_equal(2.0, result)
-        assert(wts == 4.0)
+        self.failUnless(wts == 4.0)
         ott[:] = masked
         assert_equal(average(ott,axis=0).mask, [True])
         ott = array([0.,1.,2.,3.], mask=[1,0,0,0])
@@ -104,7 +104,7 @@
         m = [1,0,0,0,0]
         d = masked_array(b,mask=m)
         c = mr_[d,0,0,d]
-        assert(isinstance(c,MaskedArray) or isinstance(c,core.MaskedArray))
+        self.failUnless(isinstance(c,MaskedArray) or isinstance(c,core.MaskedArray))
         assert_array_equal(c,[1,1,1,1,1,0,0,1,1,1,1,1])
         assert_array_equal(c.mask, mr_[m,0,0,m])
 
@@ -117,12 +117,12 @@
         b_1 = masked_array(a_1,mask=m_1)
         b_2 = masked_array(a_2,mask=m_2)
         d = mr_['1',b_1,b_2]  # append columns
-        assert(d.shape == (5,10))
+        self.failUnless(d.shape == (5,10))
         assert_array_equal(d[:,:5],b_1)
         assert_array_equal(d[:,5:],b_2)
         assert_array_equal(d.mask, np.r_['1',m_1,m_2])
         d = mr_[b_1,b_2]
-        assert(d.shape == (10,5))
+        self.failUnless(d.shape == (10,5))
         assert_array_equal(d[:5,:],b_1)
         assert_array_equal(d[5:,:],b_2)
         assert_array_equal(d.mask, np.r_[m_1,m_2])
@@ -158,14 +158,14 @@
         assert_equal(tmp[-3], slice(0,3,None))
         #
         tmp = notmasked_contiguous(a, 0)
-        assert(len(tmp[-1]) == 1)
-        assert(tmp[-2] is None)
+        self.failUnless(len(tmp[-1]) == 1)
+        self.failUnless(tmp[-2] is None)
         assert_equal(tmp[-3],tmp[-1])
-        assert(len(tmp[0]) == 2)
+        self.failUnless(len(tmp[0]) == 2)
         #
         tmp = notmasked_contiguous(a, 1)
         assert_equal(tmp[0][-1], slice(0,3,None))
-        assert(tmp[1] is None)
+        self.failUnless(tmp[1] is None)
         assert_equal(tmp[2][-1], slice(7,7,None))
         assert_equal(tmp[2][-2], slice(0,5,None))
 
@@ -205,12 +205,12 @@
         assert_equal(mask_rowcols(x,0).mask, [[1,1,1],[1,1,1],[0,0,0]] )
         assert_equal(mask_rowcols(x,1,).mask, [[1,1,0],[1,1,0],[1,1,0]] )
         x = array(x._data, mask=[[1,0,0],[0,1,0],[0,0,1]])
-        assert(mask_rowcols(x).all() is masked)
-        assert(mask_rowcols(x,0).all() is masked)
-        assert(mask_rowcols(x,1).all() is masked)
-        assert(mask_rowcols(x).mask.all())
-        assert(mask_rowcols(x,0).mask.all())
-        assert(mask_rowcols(x,1).mask.all())
+        self.failUnless(mask_rowcols(x).all() is masked)
+        self.failUnless(mask_rowcols(x,0).all() is masked)
+        self.failUnless(mask_rowcols(x,1).all() is masked)
+        self.failUnless(mask_rowcols(x).mask.all())
+        self.failUnless(mask_rowcols(x,0).mask.all())
+        self.failUnless(mask_rowcols(x,1).mask.all())
     #
     def test_dot(self):
         "Tests dot product"

Modified: trunk/numpy/ma/tests/test_mrecords.py
===================================================================
--- trunk/numpy/ma/tests/test_mrecords.py	2008-09-29 20:24:29 UTC (rev 5879)
+++ trunk/numpy/ma/tests/test_mrecords.py	2008-09-29 20:24:56 UTC (rev 5880)
@@ -264,16 +264,16 @@
         base = self.base.copy()
         mbase = base.view(mrecarray)
         mbase.harden_mask()
-        assert(mbase._hardmask)
+        self.failUnless(mbase._hardmask)
         mbase._mask = nomask
         assert_equal_records(mbase._mask, base._mask)
         mbase.soften_mask()
-        assert(not mbase._hardmask)
+        self.failUnless(not mbase._hardmask)
         mbase._mask = nomask
         # So, the mask of a field is no longer set to nomask...
         assert_equal_records(mbase._mask,
                              ma.make_mask_none(base.shape,base.dtype))
-        assert(ma.make_mask(mbase['b']._mask) is nomask)
+        self.failUnless(ma.make_mask(mbase['b']._mask) is nomask)
         assert_equal(mbase['a']._mask,mbase['b']._mask)
     #
     def test_pickling(self):
@@ -435,7 +435,7 @@
         mrectxt = fromtextfile(tmp_fl, delimitor=',',varnames='ABCDEFG')
         os.remove(tmp_fl)
         #
-        assert(isinstance(mrectxt, MaskedRecords))
+        self.failUnless(isinstance(mrectxt, MaskedRecords))
         assert_equal(mrectxt.F, [1,1,1,1])
         assert_equal(mrectxt.E._mask, [1,1,1,1])
         assert_equal(mrectxt.C, [1,2,3.e+5,-1e-10])

Modified: trunk/numpy/ma/tests/test_subclassing.py
===================================================================
--- trunk/numpy/ma/tests/test_subclassing.py	2008-09-29 20:24:29 UTC (rev 5879)
+++ trunk/numpy/ma/tests/test_subclassing.py	2008-09-29 20:24:56 UTC (rev 5880)
@@ -76,24 +76,24 @@
         m = [0,0,1,0,0]
         xsub = SubArray(x)
         xmsub = masked_array(xsub, mask=m)
-        assert isinstance(xmsub, MaskedArray)
+        self.failUnless(isinstance(xmsub, MaskedArray))
         assert_equal(xmsub._data, xsub)
-        assert isinstance(xmsub._data, SubArray)
+        self.failUnless(isinstance(xmsub._data, SubArray))
 
     def test_maskedarray_subclassing(self):
         "Tests subclassing MaskedArray"
         x = np.arange(5)
         mx = mmatrix(x,mask=[0,1,0,0,0])
-        assert isinstance(mx._data, np.matrix)
+        self.failUnless(isinstance(mx._data, np.matrix))
         "Tests masked_unary_operation"
-        assert isinstance(add(mx,mx), mmatrix)
-        assert isinstance(add(mx,x), mmatrix)
+        self.failUnless(isinstance(add(mx,mx), mmatrix))
+        self.failUnless(isinstance(add(mx,x), mmatrix))
         assert_equal(add(mx,x), mx+x)
-        assert isinstance(add(mx,mx)._data, np.matrix)
-        assert isinstance(add.outer(mx,mx), mmatrix)
+        self.failUnless(isinstance(add(mx,mx)._data, np.matrix))
+        self.failUnless(isinstance(add.outer(mx,mx), mmatrix))
         "Tests masked_binary_operation"
-        assert isinstance(hypot(mx,mx), mmatrix)
-        assert isinstance(hypot(mx,x), mmatrix)
+        self.failUnless(isinstance(hypot(mx,mx), mmatrix))
+        self.failUnless(isinstance(hypot(mx,x), mmatrix))
 
     def test_attributepropagation(self):
         x = array(arange(5), mask=[0]+[1]*4)
@@ -101,16 +101,16 @@
         ym = msubarray(x)
         #
         z = (my+1)
-        assert isinstance(z,MaskedArray)
-        assert not isinstance(z, MSubArray)
-        assert isinstance(z._data, SubArray)
+        self.failUnless(isinstance(z,MaskedArray))
+        self.failUnless(not isinstance(z, MSubArray))
+        self.failUnless(isinstance(z._data, SubArray))
         assert_equal(z._data.info, {})
         #
         z = (ym+1)
-        assert isinstance(z, MaskedArray)
-        assert isinstance(z, MSubArray)
-        assert isinstance(z._data, SubArray)
-        assert z._data.info['added'] > 0
+        self.failUnless(isinstance(z, MaskedArray))
+        self.failUnless(isinstance(z, MSubArray))
+        self.failUnless(isinstance(z._data, SubArray))
+        self.failUnless(z._data.info['added'] > 0)
         #
         ym._set_mask([1,0,0,0,1])
         assert_equal(ym._mask, [1,0,0,0,1])
@@ -119,7 +119,7 @@
         #
         xsub = subarray(x, info={'name':'x'})
         mxsub = masked_array(xsub)
-        assert hasattr(mxsub, 'info')
+        self.failUnless(hasattr(mxsub, 'info'))
         assert_equal(mxsub.info, xsub.info)
 
     def test_subclasspreservation(self):
@@ -130,22 +130,22 @@
         xsub = MSubArray(x, mask=m, info={'xsub':xinfo})
         #
         mxsub = masked_array(xsub, subok=False)
-        assert not isinstance(mxsub, MSubArray)
-        assert isinstance(mxsub, MaskedArray)
+        self.failUnless(not isinstance(mxsub, MSubArray))
+        self.failUnless(isinstance(mxsub, MaskedArray))
         assert_equal(mxsub._mask, m)
         #
         mxsub = asarray(xsub)
-        assert not isinstance(mxsub, MSubArray)
-        assert isinstance(mxsub, MaskedArray)
+        self.failUnless(not isinstance(mxsub, MSubArray))
+        self.failUnless(isinstance(mxsub, MaskedArray))
         assert_equal(mxsub._mask, m)
         #
         mxsub = masked_array(xsub, subok=True)
-        assert isinstance(mxsub, MSubArray)
+        self.failUnless(isinstance(mxsub, MSubArray))
         assert_equal(mxsub.info, xsub.info)
         assert_equal(mxsub._mask, xsub._mask)
         #
         mxsub = asanyarray(xsub)
-        assert isinstance(mxsub, MSubArray)
+        self.failUnless(isinstance(mxsub, MSubArray))
         assert_equal(mxsub.info, xsub.info)
         assert_equal(mxsub._mask, m)
 
@@ -160,16 +160,16 @@
         ym = msubarray(x)
         #
         z = (my+1)
-        assert isinstance(z,MaskedArray)
-        assert not isinstance(z, MSubArray)
-        assert isinstance(z._data, SubArray)
+        self.failUnless(isinstance(z,MaskedArray))
+        self.failUnless(not isinstance(z, MSubArray))
+        self.failUnless(isinstance(z._data, SubArray))
         assert_equal(z._data.info, {})
         #
         z = (ym+1)
-        assert isinstance(z, MaskedArray)
-        assert isinstance(z, MSubArray)
-        assert isinstance(z._data, SubArray)
-        assert z._data.info['added'] > 0
+        self.failUnless(isinstance(z, MaskedArray))
+        self.failUnless(isinstance(z, MSubArray))
+        self.failUnless(isinstance(z._data, SubArray))
+        self.failUnless(z._data.info['added'] > 0)
         #
         ym._set_mask([1,0,0,0,1])
         assert_equal(ym._mask, [1,0,0,0,1])



More information about the Numpy-svn mailing list