# [Scipy-svn] r5027 - in trunk/scipy/sparse/linalg/isolve: . tests

scipy-svn@scip... scipy-svn@scip...
Sat Nov 8 21:25:44 CST 2008

```Author: wnbell
Date: 2008-11-08 21:25:42 -0600 (Sat, 08 Nov 2008)
New Revision: 5027

Modified:
trunk/scipy/sparse/linalg/isolve/iterative.py
trunk/scipy/sparse/linalg/isolve/tests/test_iterative.py
Log:
make sure callback function is called after final iteration

Modified: trunk/scipy/sparse/linalg/isolve/iterative.py
===================================================================
--- trunk/scipy/sparse/linalg/isolve/iterative.py	2008-11-09 02:32:07 UTC (rev 5026)
+++ trunk/scipy/sparse/linalg/isolve/iterative.py	2008-11-09 03:25:42 UTC (rev 5027)
@@ -84,6 +84,8 @@
slice1 = slice(ndx1-1, ndx1-1+n)
slice2 = slice(ndx2-1, ndx2-1+n)
if (ijob == -1):
+            if callback is not None:
+                callback(x)
break
elif (ijob == 1):
work[slice2] *= sclr2
@@ -172,6 +174,8 @@
slice1 = slice(ndx1-1, ndx1-1+n)
slice2 = slice(ndx2-1, ndx2-1+n)
if (ijob == -1):
+            if callback is not None:
+                callback(x)
break
elif (ijob == 1):
if matvec is None:
@@ -262,6 +266,8 @@
slice1 = slice(ndx1-1, ndx1-1+n)
slice2 = slice(ndx2-1, ndx2-1+n)
if (ijob == -1):
+            if callback is not None:
+                callback(x)
break
elif (ijob == 1):
work[slice2] *= sclr2
@@ -346,6 +352,8 @@
slice1 = slice(ndx1-1, ndx1-1+n)
slice2 = slice(ndx2-1, ndx2-1+n)
if (ijob == -1):
+            if callback is not None:
+                callback(x)
break
elif (ijob == 1):
work[slice2] *= sclr2
@@ -559,6 +567,8 @@
slice1 = slice(ndx1-1, ndx1-1+n)
slice2 = slice(ndx2-1, ndx2-1+n)
if (ijob == -1):
+            if callback is not None:
+                callback(x)
break
elif (ijob == 1):
work[slice2] *= sclr2
@@ -585,3 +595,4 @@
ijob = 2

return postprocess(x), info
+

Modified: trunk/scipy/sparse/linalg/isolve/tests/test_iterative.py
===================================================================
--- trunk/scipy/sparse/linalg/isolve/tests/test_iterative.py	2008-11-09 02:32:07 UTC (rev 5026)
+++ trunk/scipy/sparse/linalg/isolve/tests/test_iterative.py	2008-11-09 03:25:42 UTC (rev 5027)
@@ -77,12 +77,9 @@

x, info = solver(A, b, x0=x0, tol=1e-8, maxiter=3, callback=callback)

-            assert(len(residuals) in [2,3])
+            assert_equal(len(residuals), 3)

-            # TODO enforce this condition instead!
-            #assert_equal(len(residuals), 2)

-
def test_convergence(self):
"""test whether all methods converge"""

```