[Scipy-svn] r6809 - in trunk/scipy/sparse: linalg/dsolve/tests linalg/dsolve/umfpack/tests linalg/eigen/arpack/tests linalg/eigen/lobpcg/tests linalg/isolve/tests linalg/tests tests

scipy-svn@scip... scipy-svn@scip...
Thu Sep 16 00:21:48 CDT 2010


Author: warren.weckesser
Date: 2010-09-16 00:21:48 -0500 (Thu, 16 Sep 2010)
New Revision: 6809

Modified:
   trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py
   trunk/scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py
   trunk/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py
   trunk/scipy/sparse/linalg/eigen/arpack/tests/test_speigs.py
   trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py
   trunk/scipy/sparse/linalg/isolve/tests/test_iterative.py
   trunk/scipy/sparse/linalg/isolve/tests/test_lgmres.py
   trunk/scipy/sparse/linalg/isolve/tests/test_lsqr.py
   trunk/scipy/sparse/linalg/tests/test_interface.py
   trunk/scipy/sparse/linalg/tests/test_iterative.py
   trunk/scipy/sparse/tests/test_base.py
   trunk/scipy/sparse/tests/test_construct.py
   trunk/scipy/sparse/tests/test_extract.py
   trunk/scipy/sparse/tests/test_spfuncs.py
   trunk/scipy/sparse/tests/test_sputils.py
Log:
TST: sparse: Don't use plain assert.  Don't use 'import *'.

Modified: trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py
===================================================================
--- trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py	2010-09-14 23:08:20 UTC (rev 6808)
+++ trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py	2010-09-16 05:21:48 UTC (rev 6809)
@@ -2,7 +2,8 @@
 
 from numpy import array, finfo, arange, eye, all, unique, ones, dot, matrix
 import numpy.random as random
-from numpy.testing import *
+from numpy.testing import TestCase, run_module_suite, assert_array_almost_equal, \
+    assert_raises, assert_almost_equal, assert_equal, assert_array_equal, assert_
 
 from scipy.linalg import norm, inv
 from scipy.sparse import spdiags, SparseEfficiencyWarning, csc_matrix
@@ -63,15 +64,15 @@
         x = random.rand(self.n)
         lu = splu(self.A)
         r = self.A*lu.solve(x)
-        assert abs(x - r).max() < 1e-13
+        assert_(abs(x - r).max() < 1e-13)
 
     def test_spilu_smoketest(self):
         # Check that spilu works at all
         x = random.rand(self.n)
         lu = spilu(self.A, drop_tol=1e-2, fill_factor=5)
         r = self.A*lu.solve(x)
-        assert abs(x - r).max() < 1e-2
-        assert abs(x - r).max() > 1e-5
+        assert_(abs(x - r).max() < 1e-2)
+        assert_(abs(x - r).max() > 1e-5)
 
     def test_splu_nnz0(self):
         A = csc_matrix( (5,5), dtype='d' )

Modified: trunk/scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py
===================================================================
--- trunk/scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py	2010-09-14 23:08:20 UTC (rev 6808)
+++ trunk/scipy/sparse/linalg/dsolve/umfpack/tests/test_umfpack.py	2010-09-16 05:21:48 UTC (rev 6809)
@@ -7,7 +7,8 @@
 
 import warnings
 import random
-from numpy.testing import *
+from numpy.testing import TestCase, assert_array_almost_equal, dec, \
+        decorate_methods
 
 from scipy import rand, matrix, diag, eye
 from scipy.sparse import csc_matrix, spdiags, SparseEfficiencyWarning
@@ -179,4 +180,5 @@
     decorate_methods(cls, _umfpack_skip)
 
 if __name__ == "__main__":
+    import nose
     nose.run(argv=['', __file__])

Modified: trunk/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py
===================================================================
--- trunk/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py	2010-09-14 23:08:20 UTC (rev 6808)
+++ trunk/scipy/sparse/linalg/eigen/arpack/tests/test_arpack.py	2010-09-16 05:21:48 UTC (rev 6809)
@@ -6,7 +6,9 @@
 """
 import numpy as np
 
-from numpy.testing import *
+from numpy.testing import assert_almost_equal, assert_array_almost_equal, \
+        assert_array_almost_equal_nulp, TestCase, run_module_suite, dec, \
+        verbose
 
 from numpy import array, finfo, argsort, dot, round, conj, random
 from scipy.sparse.linalg.eigen.arpack import eigen_symmetric, eigen, svd

Modified: trunk/scipy/sparse/linalg/eigen/arpack/tests/test_speigs.py
===================================================================
--- trunk/scipy/sparse/linalg/eigen/arpack/tests/test_speigs.py	2010-09-14 23:08:20 UTC (rev 6808)
+++ trunk/scipy/sparse/linalg/eigen/arpack/tests/test_speigs.py	2010-09-16 05:21:48 UTC (rev 6809)
@@ -1,9 +1,9 @@
 #!/usr/bin/env python
 
-from numpy.testing import *
+from numpy.testing import run_module_suite, TestCase, assert_array_almost_equal
 
 from scipy.sparse.linalg.interface import aslinearoperator
-from scipy.sparse.linalg.eigen.arpack.speigs import *
+from scipy.sparse.linalg.eigen.arpack import speigs
 
 import numpy as np
 
@@ -11,7 +11,7 @@
     def test(self):
         maxn=15                # Dimension of square matrix to be solved
         # Use a PDP^-1 factorisation to construct matrix with known
-        # eiegevalues/vectors. Used random eiegenvectors initially.
+        # eigenvalues/vectors. Used random eigenvectors initially.
         P = np.mat(np.random.random((maxn,)*2))
         P /= map(np.linalg.norm, P.T)            # Normalise the eigenvectors
         D = np.mat(np.zeros((maxn,)*2))
@@ -27,7 +27,7 @@
         matvec = A.matvec
         #= lambda x: np.asarray(A*x)[0]
         nev=4
-        eigvs = ARPACK_eigs(matvec, A.shape[0], nev=nev)
+        eigvs = speigs.ARPACK_eigs(matvec, A.shape[0], nev=nev)
         calc_vals = eigvs[0]
         # Ensure the calculated eigenvectors have the same sign as the reference values
         calc_vecs = eigvs[1] / [np.sign(x[0]) for x in eigvs[1].T]

Modified: trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py
===================================================================
--- trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py	2010-09-14 23:08:20 UTC (rev 6808)
+++ trunk/scipy/sparse/linalg/eigen/lobpcg/tests/test_lobpcg.py	2010-09-16 05:21:48 UTC (rev 6809)
@@ -3,7 +3,7 @@
 """
 
 import numpy
-from numpy.testing import *
+from numpy.testing import assert_almost_equal, run_module_suite
 
 from scipy import arange, ones, rand, set_printoptions, r_, diag, linalg
 from scipy.linalg import eig

Modified: trunk/scipy/sparse/linalg/isolve/tests/test_iterative.py
===================================================================
--- trunk/scipy/sparse/linalg/isolve/tests/test_iterative.py	2010-09-14 23:08:20 UTC (rev 6808)
+++ trunk/scipy/sparse/linalg/isolve/tests/test_iterative.py	2010-09-16 05:21:48 UTC (rev 6809)
@@ -2,7 +2,7 @@
 """ Test functions for the sparse.linalg.isolve module
 """
 
-from numpy.testing import *
+from numpy.testing import TestCase, assert_equal, assert_array_equal, assert_
 
 from numpy import zeros, ones, arange, array, abs, max
 from scipy.linalg import norm
@@ -101,7 +101,7 @@
                 assert_array_equal(x0, 0*b) #ensure that x0 is not overwritten
                 assert_equal(info,0)
 
-                assert( norm(b - A*x) < tol*norm(b) )
+                assert_( norm(b - A*x) < tol*norm(b) )
 
     def test_precond(self):
         """test whether all methods accept a trivial preconditioner"""
@@ -131,7 +131,7 @@
                 else:
                     x, info = solver(A, b, M=precond, x0=x0, tol=tol)
                 assert_equal(info,0)
-                assert( norm(b - A*x) < tol*norm(b) )
+                assert_( norm(b - A*x) < tol*norm(b) )
 
                 A = A.copy()
                 A.psolve  = identity
@@ -139,7 +139,7 @@
 
                 x, info = solver(A, b, x0=x0, tol=tol)
                 assert_equal(info,0)
-                assert( norm(b - A*x) < tol*norm(b) )
+                assert_( norm(b - A*x) < tol*norm(b) )
 
 
 class TestQMR(TestCase):
@@ -176,7 +176,7 @@
         x,info = qmr(A, b, tol=1e-8, maxiter=15, M1=M1, M2=M2)
 
         assert_equal(info,0)
-        assert( norm(b - A*x) < 1e-8*norm(b) )
+        assert_( norm(b - A*x) < 1e-8*norm(b) )
 
 
 class TestGMRES(TestCase):
@@ -194,8 +194,9 @@
         callback = lambda r:store_residual(r, rvec)
         x,flag = gmres(A, b, x0=zeros(A.shape[0]), tol=1e-16, maxiter=maxiter, callback=callback)
         diff = max(abs((rvec - array([1.0,   0.81649658092772603]))))
-        assert(diff < 1e-5)
+        assert_(diff < 1e-5)
 
 
 if __name__ == "__main__":
+    import nose
     nose.run(argv=['', __file__])

Modified: trunk/scipy/sparse/linalg/isolve/tests/test_lgmres.py
===================================================================
--- trunk/scipy/sparse/linalg/isolve/tests/test_lgmres.py	2010-09-14 23:08:20 UTC (rev 6808)
+++ trunk/scipy/sparse/linalg/isolve/tests/test_lgmres.py	2010-09-16 05:21:48 UTC (rev 6809)
@@ -2,7 +2,7 @@
 """Tests for the linalg.isolve.lgmres module
 """
 
-from numpy.testing import *
+from numpy.testing import TestCase, assert_
 
 from numpy import zeros, array, allclose
 from scipy.linalg import norm
@@ -28,7 +28,7 @@
     count[0] = 0
     x0, flag = lgmres(A, b, x0=zeros(A.shape[0]), inner_m=6, tol=1e-14, **kw)
     count_0 = count[0]
-    assert allclose(A*x0, b, rtol=1e-12, atol=1e-12), norm(A*x0-b)
+    assert_(allclose(A*x0, b, rtol=1e-12, atol=1e-12), norm(A*x0-b))
     return x0, count_0
 
 
@@ -41,35 +41,35 @@
         x0, count_0 = do_solve()
         x1, count_1 = do_solve(M=M)
 
-        assert count_1 == 3
-        assert count_1 < count_0/2
-        assert allclose(x1, x0, rtol=1e-14)
+        assert_(count_1 == 3)
+        assert_(count_1 < count_0/2)
+        assert_(allclose(x1, x0, rtol=1e-14))
 
     def test_outer_v(self):
         # Check that the augmentation vectors behave as expected
         
         outer_v = []
         x0, count_0 = do_solve(outer_k=6, outer_v=outer_v)
-        assert len(outer_v) > 0
-        assert len(outer_v) <= 6
+        assert_(len(outer_v) > 0)
+        assert_(len(outer_v) <= 6)
 
         x1, count_1 = do_solve(outer_k=6, outer_v=outer_v)
-        assert count_1 == 2, count_1
-        assert count_1 < count_0/2
-        assert allclose(x1, x0, rtol=1e-14)
+        assert_(count_1 == 2, count_1)
+        assert_(count_1 < count_0/2)
+        assert_(allclose(x1, x0, rtol=1e-14))
 
         # ---
 
         outer_v = []
         x0, count_0 = do_solve(outer_k=6, outer_v=outer_v, store_outer_Av=False)
-        assert array([v[1] is None for v in outer_v]).all()
-        assert len(outer_v) > 0
-        assert len(outer_v) <= 6
+        assert_(array([v[1] is None for v in outer_v]).all())
+        assert_(len(outer_v) > 0)
+        assert_(len(outer_v) <= 6)
 
         x1, count_1 = do_solve(outer_k=6, outer_v=outer_v)
-        assert count_1 == 3, count_1
-        assert count_1 < count_0/2
-        assert allclose(x1, x0, rtol=1e-14)
+        assert_(count_1 == 3, count_1)
+        assert_(count_1 < count_0/2)
+        assert_(allclose(x1, x0, rtol=1e-14))
 
 if __name__ == "__main__":
     import nose

Modified: trunk/scipy/sparse/linalg/isolve/tests/test_lsqr.py
===================================================================
--- trunk/scipy/sparse/linalg/isolve/tests/test_lsqr.py	2010-09-14 23:08:20 UTC (rev 6808)
+++ trunk/scipy/sparse/linalg/isolve/tests/test_lsqr.py	2010-09-16 05:21:48 UTC (rev 6809)
@@ -1,4 +1,5 @@
 import numpy as np
+from numpy.testing import assert_
 
 from scipy.sparse.linalg import lsqr
 from time import time
@@ -25,7 +26,7 @@
     svx = np.linalg.solve(G, b)
     X = lsqr(G, b, show=show, atol=tol, btol=tol, iter_lim=maxit)
     xo = X[0]
-    assert norm(svx - xo) < 1e-5
+    assert_(norm(svx - xo) < 1e-5)
 
 if __name__ == "__main__":
     svx = np.linalg.solve(G, b)

Modified: trunk/scipy/sparse/linalg/tests/test_interface.py
===================================================================
--- trunk/scipy/sparse/linalg/tests/test_interface.py	2010-09-14 23:08:20 UTC (rev 6808)
+++ trunk/scipy/sparse/linalg/tests/test_interface.py	2010-09-16 05:21:48 UTC (rev 6809)
@@ -1,12 +1,13 @@
 """Test functions for the sparse.linalg.interface module
 """
 
-from numpy.testing import *
+from numpy.testing import TestCase, assert_, assert_equal, \
+        assert_raises
 
 import numpy as np
 import scipy.sparse as sparse
 
-from scipy.sparse.linalg.interface import *
+from scipy.sparse.linalg import interface
 
 
 class TestLinearOperator(TestCase):
@@ -26,7 +27,7 @@
     def test_matvec(self):
 
         for matvec in self.matvecs:
-            A = LinearOperator((2,3), matvec)
+            A = interface.LinearOperator((2,3), matvec)
 
             assert_equal(A.matvec(np.array([1,2,3])),       [14,32])
             assert_equal(A.matvec(np.array([[1],[2],[3]])), [[14],[32]])
@@ -36,13 +37,13 @@
             assert_equal(A.matvec(np.matrix([[1],[2],[3]])), [[14],[32]])
             assert_equal(A * np.matrix([[1],[2],[3]]),       [[14],[32]])
 
-            assert( isinstance(A.matvec(np.array([1,2,3])),       np.ndarray) )
-            assert( isinstance(A.matvec(np.array([[1],[2],[3]])), np.ndarray) )
-            assert( isinstance(A * np.array([1,2,3]),             np.ndarray) )
-            assert( isinstance(A * np.array([[1],[2],[3]]),       np.ndarray) )
+            assert_( isinstance(A.matvec(np.array([1,2,3])),       np.ndarray) )
+            assert_( isinstance(A.matvec(np.array([[1],[2],[3]])), np.ndarray) )
+            assert_( isinstance(A * np.array([1,2,3]),             np.ndarray) )
+            assert_( isinstance(A * np.array([[1],[2],[3]]),       np.ndarray) )
 
-            assert( isinstance(A.matvec(np.matrix([[1],[2],[3]])), np.ndarray) )
-            assert( isinstance(A * np.matrix([[1],[2],[3]]),       np.ndarray) )
+            assert_( isinstance(A.matvec(np.matrix([[1],[2],[3]])), np.ndarray) )
+            assert_( isinstance(A * np.matrix([[1],[2],[3]]),       np.ndarray) )
 
             assert_raises(ValueError, A.matvec, np.array([1,2]))
             assert_raises(ValueError, A.matvec, np.array([1,2,3,4]))
@@ -84,7 +85,7 @@
     def test_basic(self):
 
         for M in self.cases:
-            A = aslinearoperator(M)
+            A = interface.aslinearoperator(M)
             M,N = A.shape
 
             assert_equal(A.matvec(np.array([1,2,3])),       [14,32])

Modified: trunk/scipy/sparse/linalg/tests/test_iterative.py
===================================================================
--- trunk/scipy/sparse/linalg/tests/test_iterative.py	2010-09-14 23:08:20 UTC (rev 6808)
+++ trunk/scipy/sparse/linalg/tests/test_iterative.py	2010-09-16 05:21:48 UTC (rev 6809)
@@ -1,7 +1,6 @@
 import numpy as np
 from numpy.testing import run_module_suite, assert_almost_equal
 
-import scipy.sparse as sp
 import scipy.sparse.linalg as spla
 
 def test_gmres_basic():

Modified: trunk/scipy/sparse/tests/test_base.py
===================================================================
--- trunk/scipy/sparse/tests/test_base.py	2010-09-14 23:08:20 UTC (rev 6808)
+++ trunk/scipy/sparse/tests/test_base.py	2010-09-16 05:21:48 UTC (rev 6809)
@@ -21,7 +21,9 @@
                   int8, ComplexWarning
 
 import random
-from numpy.testing import *
+from numpy.testing import assert_raises, assert_equal, assert_array_equal, \
+        assert_array_almost_equal, assert_almost_equal, assert_, \
+        dec, TestCase, run_module_suite
 
 import scipy.sparse as sparse
 from scipy.sparse import csc_matrix, csr_matrix, dok_matrix, \
@@ -250,7 +252,7 @@
 
         B = A.asfptype()
         C = B.asfptype()
-        assert( B is C )
+        assert_( B is C )
 
 
     def test_mul_scalar(self):
@@ -356,7 +358,7 @@
         """
         A = self.spmatrix([[1],[2],[3]])
 
-        assert(isspmatrix(A * array(1)))
+        assert_(isspmatrix(A * array(1)))
         assert_equal((A * array(1)).todense(), [[1],[2],[3]])
         assert_equal(A * array([1]), array([1,2,3]))
         assert_equal(A * array([[1]]), array([[1],[2],[3]]))
@@ -372,8 +374,8 @@
         assert_equal((M * matrix([[1],[2],[3]])).shape,(4,1))
 
         #check result type
-        assert(isinstance( M * array([1,2,3]), ndarray))
-        assert(isinstance( M * matrix([1,2,3]).T, matrix))
+        assert_(isinstance( M * array([1,2,3]), ndarray))
+        assert_(isinstance( M * matrix([1,2,3]).T, matrix))
 
         #ensure exception is raised for improper dimensions
         bad_vecs = [array([1,2]), array([1,2,3,4]), array([[1],[2]]),
@@ -464,7 +466,7 @@
 
         for b in bs:
             result = asp*b
-            assert( isinstance(result, type(b)) )
+            assert_( isinstance(result, type(b)) )
             assert_equal( result.shape, (4,2) )
             assert_equal( result, dot(a,b) )
 
@@ -556,7 +558,7 @@
         B = A.copy()
         try:
             B[0,0] += 1
-            assert B[0,0]!=A[0,0]
+            assert_(B[0,0] != A[0,0])
         except NotImplementedError:
             # not all sparse matrices can be indexed
             pass
@@ -689,7 +691,7 @@
             a = A[6,3:7]
         except IndexError:
             caught += 1
-        assert caught == 2
+        assert_(caught == 2)
 
 
 class _TestVertSlicing:
@@ -724,7 +726,7 @@
             a = A[6,3:7]
         except IndexError:
             caught += 1
-        assert caught == 2
+        assert_(caught == 2)
 
 
 

Modified: trunk/scipy/sparse/tests/test_construct.py
===================================================================
--- trunk/scipy/sparse/tests/test_construct.py	2010-09-14 23:08:20 UTC (rev 6808)
+++ trunk/scipy/sparse/tests/test_construct.py	2010-09-16 05:21:48 UTC (rev 6809)
@@ -2,12 +2,13 @@
 
 import numpy as np
 from numpy import array, matrix
-from numpy.testing import *
+from numpy.testing import TestCase, run_module_suite, assert_equal, \
+        assert_array_equal, assert_raises
 
 
 from scipy.sparse import csr_matrix, coo_matrix
 
-from scipy.sparse.construct import *
+from scipy.sparse import construct
 from scipy.sparse.construct import rand as sprand
 
 sparse_formats = ['csr','csc','coo','bsr','dia','lil','dok']
@@ -60,34 +61,34 @@
                                                  [ 0, 2, 0, 0,15]]) )
 
         for d,o,m,n,result in cases:
-            assert_equal( spdiags(d,o,m,n).todense(), result )
+            assert_equal( construct.spdiags(d,o,m,n).todense(), result )
 
 
     def test_identity(self):
-        assert_equal(identity(1).toarray(), [[1]])
-        assert_equal(identity(2).toarray(), [[1,0],[0,1]])
+        assert_equal(construct.identity(1).toarray(), [[1]])
+        assert_equal(construct.identity(2).toarray(), [[1,0],[0,1]])
 
-        I = identity(3, dtype='int8', format='dia')
+        I = construct.identity(3, dtype='int8', format='dia')
         assert_equal( I.dtype, np.dtype('int8') )
         assert_equal( I.format, 'dia' )
 
         for fmt in sparse_formats:
-            I = identity( 3, format=fmt )
+            I = construct.identity( 3, format=fmt )
             assert_equal( I.format, fmt )
             assert_equal( I.toarray(), [[1,0,0],[0,1,0],[0,0,1]])
 
     def test_eye(self):
-        assert_equal(eye(1,1).toarray(), [[1]])
-        assert_equal(eye(2,3).toarray(), [[1,0,0],[0,1,0]])
-        assert_equal(eye(3,2).toarray(), [[1,0],[0,1],[0,0]])
-        assert_equal(eye(3,3).toarray(), [[1,0,0],[0,1,0],[0,0,1]])
+        assert_equal(construct.eye(1,1).toarray(), [[1]])
+        assert_equal(construct.eye(2,3).toarray(), [[1,0,0],[0,1,0]])
+        assert_equal(construct.eye(3,2).toarray(), [[1,0],[0,1],[0,0]])
+        assert_equal(construct.eye(3,3).toarray(), [[1,0,0],[0,1,0],[0,0,1]])
 
-        assert_equal(eye(3,3,dtype='int16').dtype, np.dtype('int16'))
+        assert_equal(construct.eye(3,3,dtype='int16').dtype, np.dtype('int16'))
 
         for m in [3, 5]:
             for n in [3, 5]:
                 for k in range(-5,6):
-                    assert_equal(eye(m, n, k=k).toarray(), np.eye(m, n, k=k))
+                    assert_equal(construct.eye(m, n, k=k).toarray(), np.eye(m, n, k=k))
 
     def test_kron(self):
         cases = []
@@ -108,7 +109,7 @@
 
         for a in cases:
             for b in cases:
-                result   = kron(csr_matrix(a),csr_matrix(b)).todense()
+                result   = construct.kron(csr_matrix(a),csr_matrix(b)).todense()
                 expected = np.kron(a,b)
                 assert_array_equal(result,expected)
 
@@ -126,7 +127,7 @@
 
         for a in cases:
             for b in cases:
-                result   = kronsum(csr_matrix(a),csr_matrix(b)).todense()
+                result   = construct.kronsum(csr_matrix(a),csr_matrix(b)).todense()
                 expected = np.kron(np.eye(len(b)), a) + \
                         np.kron(b, np.eye(len(a)))
                 assert_array_equal(result,expected)
@@ -139,7 +140,7 @@
         expected = matrix([[1, 2],
                            [3, 4],
                            [5, 6]])
-        assert_equal( vstack( [A,B] ).todense(), expected )
+        assert_equal( construct.vstack( [A,B] ).todense(), expected )
 
     def test_hstack(self):
 
@@ -148,7 +149,7 @@
 
         expected = matrix([[1, 2, 5],
                            [3, 4, 6]])
-        assert_equal( hstack( [A,B] ).todense(), expected )
+        assert_equal( construct.hstack( [A,B] ).todense(), expected )
 
     def test_bmat(self):
 
@@ -159,47 +160,47 @@
         expected = matrix([[1, 2, 5],
                            [3, 4, 6],
                            [0, 0, 7]])
-        assert_equal( bmat( [[A,B],[None,C]] ).todense(), expected )
+        assert_equal( construct.bmat( [[A,B],[None,C]] ).todense(), expected )
 
 
         expected = matrix([[1, 2, 0],
                            [3, 4, 0],
                            [0, 0, 7]])
-        assert_equal( bmat( [[A,None],[None,C]] ).todense(), expected )
+        assert_equal( construct.bmat( [[A,None],[None,C]] ).todense(), expected )
 
         expected = matrix([[0, 5],
                            [0, 6],
                            [7, 0]])
-        assert_equal( bmat( [[None,B],[C,None]] ).todense(), expected )
+        assert_equal( construct.bmat( [[None,B],[C,None]] ).todense(), expected )
 
         #TODO test failure cases
 
     def test_lil_diags(self):
-        assert_array_equal(lil_diags([[1,2,3],[4,5],[6]],
+        assert_array_equal(construct.lil_diags([[1,2,3],[4,5],[6]],
                                      [0,1,2],(3,3)).todense(),
                            [[1,4,6],
                             [0,2,5],
                             [0,0,3]])
 
-        assert_array_equal(lil_diags([[6],[4,5],[1,2,3]],
+        assert_array_equal(construct.lil_diags([[6],[4,5],[1,2,3]],
                                      [2,1,0],(3,3)).todense(),
                            [[1,4,6],
                             [0,2,5],
                             [0,0,3]])
 
-        assert_array_equal(lil_diags([[6,7,8],[4,5],[1,2,3]],
+        assert_array_equal(construct.lil_diags([[6,7,8],[4,5],[1,2,3]],
                                      [2,1,0],(3,3)).todense(),
                            [[1,4,6],
                             [0,2,5],
                             [0,0,3]])
 
-        assert_array_equal(lil_diags([[1,2,3],[4,5],[6]],
+        assert_array_equal(construct.lil_diags([[1,2,3],[4,5],[6]],
                                      [0,-1,-2],(3,3)).todense(),
                            [[1,0,0],
                             [4,2,0],
                             [6,5,3]])
 
-        assert_array_equal(lil_diags([[6,7,8],[4,5]],
+        assert_array_equal(construct.lil_diags([[6,7,8],[4,5]],
                                      [-2,-1],(3,3)).todense(),
                            [[0,0,0],
                             [4,0,0],

Modified: trunk/scipy/sparse/tests/test_extract.py
===================================================================
--- trunk/scipy/sparse/tests/test_extract.py	2010-09-14 23:08:20 UTC (rev 6808)
+++ trunk/scipy/sparse/tests/test_extract.py	2010-09-16 05:21:48 UTC (rev 6809)
@@ -1,10 +1,10 @@
 """test sparse matrix construction functions"""
 
-from numpy.testing import *
+from numpy.testing import TestCase, assert_equal
 from scipy.sparse import csr_matrix
 
 import numpy as np
-from scipy.sparse.extract import *
+from scipy.sparse import extract
 
 
 class TestExtract(TestCase):
@@ -28,17 +28,17 @@
 
     def find(self):
         for A in self.cases:
-            I,J,V = find(A)
+            I,J,V = extract.find(A)
             assert_equal( A.toarray(), csr_matrix(((I,J),V), shape=A.shape) )
 
     def test_tril(self):
         for A in self.cases:
             B = A.toarray()
             for k in [-3,-2,-1,0,1,2,3]:
-                assert_equal( tril(A,k=k).toarray(), np.tril(B,k=k))
+                assert_equal( extract.tril(A,k=k).toarray(), np.tril(B,k=k))
 
     def test_triu(self):
         for A in self.cases:
             B = A.toarray()
             for k in [-3,-2,-1,0,1,2,3]:
-                assert_equal( triu(A,k=k).toarray(), np.triu(B,k=k))
+                assert_equal( extract.triu(A,k=k).toarray(), np.triu(B,k=k))

Modified: trunk/scipy/sparse/tests/test_spfuncs.py
===================================================================
--- trunk/scipy/sparse/tests/test_spfuncs.py	2010-09-14 23:08:20 UTC (rev 6808)
+++ trunk/scipy/sparse/tests/test_spfuncs.py	2010-09-16 05:21:48 UTC (rev 6809)
@@ -1,7 +1,7 @@
 from numpy import array, kron, matrix, diag
-from numpy.testing import *
+from numpy.testing import TestCase, run_module_suite, assert_, assert_equal
 
-from scipy.sparse.spfuncs import *
+from scipy.sparse import spfuncs
 from scipy.sparse import csr_matrix, csc_matrix, bsr_matrix
 from scipy.sparse.sparsetools import csr_scale_rows, csr_scale_columns, \
         bsr_scale_rows, bsr_scale_columns
@@ -65,9 +65,9 @@
         for A in mats:
             for B in blks:
                 X = kron(A,B)
-                r,c = estimate_blocksize(X)
-                assert(r >= B.shape[0])
-                assert(c >= B.shape[1])
+                r,c = spfuncs.estimate_blocksize(X)
+                assert_(r >= B.shape[0])
+                assert_(c >= B.shape[1])
 
     def test_count_blocks(self):
         def gold(A,bs):
@@ -90,12 +90,12 @@
                 Y = csr_matrix(X)
                 for R in range(1,6):
                     for C in range(1,6):
-                        assert_equal(count_blocks(Y,(R,C)),gold(X,(R,C)))
+                        assert_equal(spfuncs.count_blocks(Y, (R, C)), gold(X, (R, C)))
 
         X = kron([[1,1,0],[0,0,1],[1,0,1]],[[1,1]])
         Y = csc_matrix(X)
-        assert_equal(count_blocks(X,(1,2)),gold(X,(1,2)))
-        assert_equal(count_blocks(Y,(1,2)),gold(X,(1,2)))
+        assert_equal(spfuncs.count_blocks(X, (1, 2)), gold(X, (1, 2)))
+        assert_equal(spfuncs.count_blocks(Y, (1, 2)), gold(X, (1, 2)))
 
     def test_cs_graph_components(self):
         import numpy as np
@@ -104,19 +104,19 @@
         D = np.eye(4, dtype=np.bool)
 
         n_comp, flag = cs_graph_components(csr_matrix(D))
-        assert(n_comp == 4)
+        assert_(n_comp == 4)
         assert_equal(flag, [0, 1, 2, 3])
 
         D[0,1] = D[1,0] = 1
 
         n_comp, flag = cs_graph_components(csr_matrix(D))
-        assert(n_comp == 3)
+        assert_(n_comp == 3)
         assert_equal(flag, [0, 0, 1, 2])
 
         # A pathological case...
         D[2,2] = 0
         n_comp, flag = cs_graph_components(csr_matrix(D))
-        assert(n_comp == 2)
+        assert_(n_comp == 2)
         assert_equal(flag, [0, 0, -2, 1])
 
 if __name__ == "__main__":

Modified: trunk/scipy/sparse/tests/test_sputils.py
===================================================================
--- trunk/scipy/sparse/tests/test_sputils.py	2010-09-14 23:08:20 UTC (rev 6808)
+++ trunk/scipy/sparse/tests/test_sputils.py	2010-09-16 05:21:48 UTC (rev 6809)
@@ -1,69 +1,69 @@
 """unit tests for sparse utility functions"""
 
 import numpy as np
-from numpy.testing import *
-from scipy.sparse.sputils import *
+from numpy.testing import TestCase, run_module_suite, assert_equal
+from scipy.sparse import sputils
 
 
 class TestSparseUtils(TestCase):
 
     def test_upcast(self):
-        assert_equal(upcast('intc'),np.intc)
-        assert_equal(upcast('int32','float32'),np.float64)
-        assert_equal(upcast('bool',complex,float),np.complex128)
-        assert_equal(upcast('i','d'),np.float64)
+        assert_equal(sputils.upcast('intc'),np.intc)
+        assert_equal(sputils.upcast('int32','float32'),np.float64)
+        assert_equal(sputils.upcast('bool',complex,float),np.complex128)
+        assert_equal(sputils.upcast('i','d'),np.float64)
 
     def test_getdtype(self):
         A = np.array([1],dtype='int8')
 
-        assert_equal(getdtype(None,default=float),np.float)
-        assert_equal(getdtype(None,a=A),np.int8)
+        assert_equal(sputils.getdtype(None,default=float),np.float)
+        assert_equal(sputils.getdtype(None,a=A),np.int8)
 
     def test_isscalarlike(self):
-        assert_equal(isscalarlike(3.0),True)
-        assert_equal(isscalarlike(-4),True)
-        assert_equal(isscalarlike(2.5),True)
-        assert_equal(isscalarlike(1 + 3j),True)
-        assert_equal(isscalarlike(np.array(3)),True)
-        assert_equal(isscalarlike( "16" ), True)
+        assert_equal(sputils.isscalarlike(3.0),True)
+        assert_equal(sputils.isscalarlike(-4),True)
+        assert_equal(sputils.isscalarlike(2.5),True)
+        assert_equal(sputils.isscalarlike(1 + 3j),True)
+        assert_equal(sputils.isscalarlike(np.array(3)),True)
+        assert_equal(sputils.isscalarlike( "16" ), True)
 
-        assert_equal(isscalarlike( np.array([3])), False)
-        assert_equal(isscalarlike( [[3]] ), False)
-        assert_equal(isscalarlike( (1,) ), False)
-        assert_equal(isscalarlike( (1,2) ), False)
+        assert_equal(sputils.isscalarlike( np.array([3])), False)
+        assert_equal(sputils.isscalarlike( [[3]] ), False)
+        assert_equal(sputils.isscalarlike( (1,) ), False)
+        assert_equal(sputils.isscalarlike( (1,2) ), False)
 
     def test_isintlike(self):
-        assert_equal(isintlike(3.0),True)
-        assert_equal(isintlike(-4),True)
-        assert_equal(isintlike(np.array(3)),True)
-        assert_equal(isintlike(np.array([3])), False)
+        assert_equal(sputils.isintlike(3.0),True)
+        assert_equal(sputils.isintlike(-4),True)
+        assert_equal(sputils.isintlike(np.array(3)),True)
+        assert_equal(sputils.isintlike(np.array([3])), False)
 
-        assert_equal(isintlike(2.5),False)
-        assert_equal(isintlike(1 + 3j),False)
-        assert_equal(isintlike( (1,) ), False)
-        assert_equal(isintlike( (1,2) ), False)
+        assert_equal(sputils.isintlike(2.5),False)
+        assert_equal(sputils.isintlike(1 + 3j),False)
+        assert_equal(sputils.isintlike( (1,) ), False)
+        assert_equal(sputils.isintlike( (1,2) ), False)
 
     def test_isshape(self):
-        assert_equal(isshape( (1,2) ),True)
-        assert_equal(isshape( (5,2) ),True)
+        assert_equal(sputils.isshape( (1,2) ),True)
+        assert_equal(sputils.isshape( (5,2) ),True)
 
-        assert_equal(isshape( (1.5,2) ),False)
-        assert_equal(isshape( (2,2,2) ),False)
-        assert_equal(isshape( ([2],2) ),False)
+        assert_equal(sputils.isshape( (1.5,2) ),False)
+        assert_equal(sputils.isshape( (2,2,2) ),False)
+        assert_equal(sputils.isshape( ([2],2) ),False)
 
     def test_issequence(self):
-        assert_equal(issequence( (1,) ),True)
-        assert_equal(issequence( (1,2,3) ),True)
-        assert_equal(issequence( [1] ),True)
-        assert_equal(issequence( [1,2,3] ),True)
-        assert_equal(issequence( np.array([1,2,3]) ),True)
+        assert_equal(sputils.issequence( (1,) ),True)
+        assert_equal(sputils.issequence( (1,2,3) ),True)
+        assert_equal(sputils.issequence( [1] ),True)
+        assert_equal(sputils.issequence( [1,2,3] ),True)
+        assert_equal(sputils.issequence( np.array([1,2,3]) ),True)
 
-        assert_equal(issequence( np.array([[1],[2],[3]]) ),False)
-        assert_equal(issequence( 3 ),False)
+        assert_equal(sputils.issequence( np.array([[1],[2],[3]]) ),False)
+        assert_equal(sputils.issequence( 3 ),False)
 
     def test_isdense(self):
-        assert_equal(isdense( np.array([1]) ),True)
-        assert_equal(isdense( np.matrix([1]) ),True)
+        assert_equal(sputils.isdense( np.array([1]) ),True)
+        assert_equal(sputils.isdense( np.matrix([1]) ),True)
 
 if __name__ == "__main__":
     run_module_suite()



More information about the Scipy-svn mailing list