[Scipy-svn] r6792 - trunk/scipy/linalg/tests

scipy-svn@scip... scipy-svn@scip...
Sun Sep 12 16:20:23 CDT 2010


Author: warren.weckesser
Date: 2010-09-12 16:20:23 -0500 (Sun, 12 Sep 2010)
New Revision: 6792

Modified:
   trunk/scipy/linalg/tests/test_basic.py
   trunk/scipy/linalg/tests/test_build.py
   trunk/scipy/linalg/tests/test_decomp.py
   trunk/scipy/linalg/tests/test_fblas.py
   trunk/scipy/linalg/tests/test_lapack.py
   trunk/scipy/linalg/tests/test_special_matrices.py
Log:
TST: linalg: Don't use plain 'assert'.

Modified: trunk/scipy/linalg/tests/test_basic.py
===================================================================
--- trunk/scipy/linalg/tests/test_basic.py	2010-09-12 21:19:54 UTC (rev 6791)
+++ trunk/scipy/linalg/tests/test_basic.py	2010-09-12 21:20:23 UTC (rev 6792)
@@ -26,7 +26,7 @@
 import numpy.linalg as linalg
 
 from numpy.testing import TestCase, rand, run_module_suite, assert_raises, \
-    assert_equal, assert_almost_equal, assert_array_almost_equal
+    assert_equal, assert_almost_equal, assert_array_almost_equal, assert_
 
 from scipy.linalg import solve, inv, det, lstsq, pinv, pinv2, norm,\
         solve_banded, solveh_banded
@@ -498,7 +498,7 @@
         for i in range(4):
             b = random([n,3])
             x,res,r,s = lstsq(a,b)
-            assert r==m,'unexpected efficient rank'
+            assert_(r == m, 'unexpected efficient rank')
             #XXX: check definition of res
             assert_array_almost_equal(x,direct_lstsq(a,b))
 
@@ -511,7 +511,7 @@
         for i in range(2):
             b = random([n,3])
             x,res,r,s = lstsq(a,b)
-            assert r==m,'unexpected efficient rank'
+            assert_(r == m, 'unexpected efficient rank')
             #XXX: check definition of res
             assert_array_almost_equal(x,direct_lstsq(a,b,1))
 

Modified: trunk/scipy/linalg/tests/test_build.py
===================================================================
--- trunk/scipy/linalg/tests/test_build.py	2010-09-12 21:19:54 UTC (rev 6791)
+++ trunk/scipy/linalg/tests/test_build.py	2010-09-12 21:20:23 UTC (rev 6792)
@@ -2,7 +2,6 @@
 import sys
 import re
 
-import numpy as np
 from numpy.testing import TestCase, dec
 from numpy.compat import asbytes
 

Modified: trunk/scipy/linalg/tests/test_decomp.py
===================================================================
--- trunk/scipy/linalg/tests/test_decomp.py	2010-09-12 21:19:54 UTC (rev 6791)
+++ trunk/scipy/linalg/tests/test_decomp.py	2010-09-12 21:20:23 UTC (rev 6792)
@@ -16,7 +16,7 @@
 
 import numpy as np
 from numpy.testing import TestCase, assert_equal, assert_array_almost_equal, \
-        assert_array_equal, assert_raises, run_module_suite, dec
+        assert_array_equal, assert_raises, assert_, run_module_suite, dec
 
 from scipy.linalg import eig, eigvals, lu, svd, svdvals, cholesky, qr, \
      schur, rsf2csf, lu_solve, lu_factor, solve, diagsvd, hessenberg, rq, \
@@ -47,7 +47,7 @@
     else:
         des = dtype(des)
 
-    assert act == des, 'dtype mismatch: "%s" (should be "%s") '%(act, des)
+    assert_(act == des, 'dtype mismatch: "%s" (should be "%s") ' % (act, des))
 
 # XXX: This function should not be defined here, but somewhere in
 #      scipy.linalg namespace
@@ -753,38 +753,38 @@
     def test_simple(self):
         a = [[1,2,3],[1,2,3],[2,5,6]]
         s = svdvals(a)
-        assert len(s)==3
-        assert s[0]>=s[1]>=s[2]
+        assert_(len(s) == 3)
+        assert_(s[0] >= s[1] >= s[2])
 
     def test_simple_underdet(self):
         a = [[1,2,3],[4,5,6]]
         s = svdvals(a)
-        assert len(s)==2
-        assert s[0]>=s[1]
+        assert_(len(s) == 2)
+        assert_(s[0] >= s[1])
 
     def test_simple_overdet(self):
         a = [[1,2],[4,5],[3,4]]
         s = svdvals(a)
-        assert len(s)==2
-        assert s[0]>=s[1]
+        assert_(len(s) == 2)
+        assert_(s[0] >= s[1])
 
     def test_simple_complex(self):
         a = [[1,2,3],[1,20,3j],[2,5,6]]
         s = svdvals(a)
-        assert len(s)==3
-        assert s[0]>=s[1]>=s[2]
+        assert_(len(s) == 3)
+        assert_(s[0] >= s[1] >= s[2])
 
     def test_simple_underdet_complex(self):
         a = [[1,2,3],[4,5j,6]]
         s = svdvals(a)
-        assert len(s)==2
-        assert s[0]>=s[1]
+        assert_(len(s) == 2)
+        assert_(s[0] >= s[1])
 
     def test_simple_overdet_complex(self):
         a = [[1,2],[4,5],[3j,4]]
         s = svdvals(a)
-        assert len(s)==2
-        assert s[0]>=s[1]
+        assert_(len(s) == 2)
+        assert_(s[0] >= s[1])
 
 class TestDiagSVD(TestCase):
 
@@ -947,7 +947,7 @@
         t,z = schur(a)
         assert_array_almost_equal(dot(dot(z,t),transp(conj(z))),a)
         tc,zc = schur(a,'complex')
-        assert(any(ravel(iscomplex(zc))) and any(ravel(iscomplex(tc))))
+        assert_(any(ravel(iscomplex(zc))) and any(ravel(iscomplex(tc))))
         assert_array_almost_equal(dot(dot(zc,tc),transp(conj(zc))),a)
         tc2,zc2 = rsf2csf(tc,zc)
         assert_array_almost_equal(dot(dot(zc2,tc2),transp(conj(zc2))),a)

Modified: trunk/scipy/linalg/tests/test_fblas.py
===================================================================
--- trunk/scipy/linalg/tests/test_fblas.py	2010-09-12 21:19:54 UTC (rev 6791)
+++ trunk/scipy/linalg/tests/test_fblas.py	2010-09-12 21:20:23 UTC (rev 6792)
@@ -11,7 +11,7 @@
 from scipy.linalg import fblas
 
 from numpy.testing import TestCase, run_module_suite, assert_array_equal, \
-    assert_array_almost_equal
+    assert_array_almost_equal, assert_
 
 
 #decimal accuracy to require between Python and LAPACK/BLAS calculations
@@ -25,7 +25,7 @@
         b = b[:,newaxis]
     else:
         b_is_vector = False
-    assert a.shape[1] == b.shape[0]
+    assert_(a.shape[1] == b.shape[0])
     c = zeros((a.shape[0], b.shape[1]), common_type(a, b))
     for i in xrange(a.shape[0]):
         for j in xrange(b.shape[1]):

Modified: trunk/scipy/linalg/tests/test_lapack.py
===================================================================
--- trunk/scipy/linalg/tests/test_lapack.py	2010-09-12 21:19:54 UTC (rev 6791)
+++ trunk/scipy/linalg/tests/test_lapack.py	2010-09-12 21:20:23 UTC (rev 6792)
@@ -4,7 +4,7 @@
 #
 
 from numpy.testing import TestCase, run_module_suite, assert_equal, \
-    assert_array_almost_equal
+    assert_array_almost_equal, assert_
 from numpy import ones
 
 from scipy.linalg import flapack, clapack
@@ -22,13 +22,13 @@
             f = getattr(flapack,p+'gebal',None)
             if f is None: continue
             ba,lo,hi,pivscale,info = f(a)
-            assert not info,`info`
+            assert_(not info,`info`)
             assert_array_almost_equal(ba,a)
             assert_equal((lo,hi),(0,len(a[0])-1))
             assert_array_almost_equal(pivscale,ones(len(a)))
 
             ba,lo,hi,pivscale,info = f(a1,permute=1,scale=1)
-            assert not info,`info`
+            assert_(not info,`info`)
             #print a1
             #print ba,lo,hi,pivscale
 
@@ -40,7 +40,7 @@
             f = getattr(flapack,p+'gehrd',None)
             if f is None: continue
             ht,tau,info = f(a)
-            assert not info,`info`
+            assert_(not info,`info`)
 
 class TestLapack(TestCase):
 

Modified: trunk/scipy/linalg/tests/test_special_matrices.py
===================================================================
--- trunk/scipy/linalg/tests/test_special_matrices.py	2010-09-12 21:19:54 UTC (rev 6791)
+++ trunk/scipy/linalg/tests/test_special_matrices.py	2010-09-12 21:20:23 UTC (rev 6792)
@@ -1,6 +1,6 @@
 """Tests for functions in special_matrices.py."""
 
-from numpy import arange, add, array, eye, all, copy
+from numpy import arange, add, array, eye, copy
 from numpy.testing import TestCase, run_module_suite, assert_raises, \
     assert_equal, assert_array_equal
 
@@ -216,12 +216,12 @@
 class TestBlockDiag:
     def test_basic(self):
         x = block_diag(eye(2), [[1,2], [3,4], [5,6]], [[1, 2, 3]])
-        assert all(x == [[1, 0, 0, 0, 0, 0, 0],
-                         [0, 1, 0, 0, 0, 0, 0],
-                         [0, 0, 1, 2, 0, 0, 0],
-                         [0, 0, 3, 4, 0, 0, 0],
-                         [0, 0, 5, 6, 0, 0, 0],
-                         [0, 0, 0, 0, 1, 2, 3]])
+        assert_array_equal(x, [[1, 0, 0, 0, 0, 0, 0],
+                               [0, 1, 0, 0, 0, 0, 0],
+                               [0, 0, 1, 2, 0, 0, 0],
+                               [0, 0, 3, 4, 0, 0, 0],
+                               [0, 0, 5, 6, 0, 0, 0],
+                               [0, 0, 0, 0, 1, 2, 3]])
 
     def test_dtype(self):
         x = block_diag([[1.5]])



More information about the Scipy-svn mailing list