[Scipy-svn] r6811 - in trunk/scipy/sparse/linalg/dsolve: . tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Sat Sep 18 00:41:54 EDT 2010
Author: warren.weckesser
Date: 2010-09-17 23:41:54 -0500 (Fri, 17 Sep 2010)
New Revision: 6811
Modified:
trunk/scipy/sparse/linalg/dsolve/linsolve.py
trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py
Log:
sparse: update some 'raise' statements; a few other minor tweaks
Modified: trunk/scipy/sparse/linalg/dsolve/linsolve.py
===================================================================
--- trunk/scipy/sparse/linalg/dsolve/linsolve.py 2010-09-17 13:43:22 UTC (rev 6810)
+++ trunk/scipy/sparse/linalg/dsolve/linsolve.py 2010-09-18 04:41:54 UTC (rev 6811)
@@ -51,7 +51,7 @@
if max( b.shape ) == b.size:
b = b.squeeze()
else:
- raise ValueError, "rhs must be a vector (has shape %s)" % (b.shape,)
+ raise ValueError("rhs must be a vector (has shape %s)" % (b.shape,))
if not (isspmatrix_csc(A) or isspmatrix_csr(A)):
A = csc_matrix(A)
@@ -64,18 +64,18 @@
if (M != N):
raise ValueError("matrix must be square (has shape %s)" % ((M, N),))
if M != b.size:
- raise ValueError("matrix - rhs size mismatch (%s - %s)"\
+ raise ValueError("matrix - rhs size mismatch (%s - %s)"
% (A.shape, b.size))
use_umfpack = use_umfpack and useUmfpack
if isUmfpack and use_umfpack:
if noScikit:
- warn( 'scipy.sparse.linalg.dsolve.umfpack will be removed,'\
+ warn( 'scipy.sparse.linalg.dsolve.umfpack will be removed,'
' install scikits.umfpack instead', DeprecationWarning )
if A.dtype.char not in 'dD':
- raise ValueError, "convert matrix data to double, please, using"\
- " .astype(), or set linsolve.useUmfpack = False"
+ raise ValueError("convert matrix data to double, please, using"
+ " .astype(), or set linsolve.useUmfpack = False")
b = asarray(b, dtype=A.dtype).reshape(-1)
@@ -163,7 +163,7 @@
M, N = A.shape
if (M != N):
- raise ValueError, "can only factor square matrices" #is this true?
+ raise ValueError("can only factor square matrices") #is this true?
_options = dict(DiagPivotThresh=diag_pivot_thresh, ColPerm=permc_spec,
PanelSize=panel_size, Relax=relax)
@@ -233,7 +233,7 @@
M, N = A.shape
if (M != N):
- raise ValueError, "can only factor square matrices" #is this true?
+ raise ValueError("can only factor square matrices") #is this true?
_options = dict(ILU_DropRule=drop_rule, ILU_DropTol=drop_tol,
ILU_FillFactor=fill_factor,
@@ -255,7 +255,7 @@
"""
if isUmfpack and useUmfpack:
if noScikit:
- warn( 'scipy.sparse.linalg.dsolve.umfpack will be removed,'\
+ warn( 'scipy.sparse.linalg.dsolve.umfpack will be removed,'
' install scikits.umfpack instead', DeprecationWarning )
if not isspmatrix_csc(A):
@@ -266,8 +266,8 @@
A = A.asfptype() #upcast to a floating point format
if A.dtype.char not in 'dD':
- raise ValueError, "convert matrix data to double, please, using"\
- " .astype(), or set linsolve.useUmfpack = False"
+ raise ValueError("convert matrix data to double, please, using"
+ " .astype(), or set linsolve.useUmfpack = False")
family = {'d' : 'di', 'D' : 'zi'}
umf = umfpack.UmfpackContext( family[A.dtype.char] )
Modified: trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py
===================================================================
--- trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py 2010-09-17 13:43:22 UTC (rev 6810)
+++ trunk/scipy/sparse/linalg/dsolve/tests/test_linsolve.py 2010-09-18 04:41:54 UTC (rev 6811)
@@ -37,7 +37,7 @@
x = spsolve(Asp,b)
- assert( norm(b - Asp*x) < 10 * cond_A * eps )
+ assert_( norm(b - Asp*x) < 10 * cond_A * eps )
def test_smoketest(self):
Adense = matrix([[ 0., 1., 1.],
@@ -52,9 +52,14 @@
assert_array_almost_equal(x, x2)
def test_non_square(self):
+ # A is not square.
A = ones((3, 4))
b = ones((4, 1))
assert_raises(ValueError, spsolve, A, b)
+ # A2 and b2 have incompatible shapes.
+ A2 = csc_matrix(eye(3))
+ b2 = array([1.0, 2.0])
+ assert_raises(ValueError, spsolve, A2, b2)
class TestSplu(object):
def setUp(self):
More information about the Scipy-svn
mailing list