[Numpy-svn] r5104 - in trunk/numpy/linalg: . tests

numpy-svn@scip... numpy-svn@scip...
Sun Apr 27 13:44:49 CDT 2008


Author: charris
Date: 2008-04-27 13:44:47 -0500 (Sun, 27 Apr 2008)
New Revision: 5104

Modified:
   trunk/numpy/linalg/linalg.py
   trunk/numpy/linalg/tests/test_linalg.py
Log:
Fix test of lstsqr to work with matrix tests.
Fix lstsq


Modified: trunk/numpy/linalg/linalg.py
===================================================================
--- trunk/numpy/linalg/linalg.py	2008-04-27 18:19:12 UTC (rev 5103)
+++ trunk/numpy/linalg/linalg.py	2008-04-27 18:44:47 UTC (rev 5104)
@@ -1147,10 +1147,10 @@
 
     """
     import math
-    a = _makearray(a)
+    a, _ = _makearray(a)
     b, wrap = _makearray(b)
-    one_eq = len(b.shape) == 1
-    if one_eq:
+    is_1d = len(b.shape) == 1
+    if is_1d:
         b = b[:, newaxis]
     _assertRank2(a, b)
     m  = a.shape[0]
@@ -1199,7 +1199,7 @@
     if results['info'] > 0:
         raise LinAlgError, 'SVD did not converge in Linear Least Squares'
     resids = array([], t)
-    if one_eq:
+    if is_1d:
         x = array(ravel(bstar)[:n], dtype=result_t, copy=True)
         if results['rank'] == n and m > n:
             resids = array([sum((ravel(bstar)[n:])**2)], dtype=result_t)

Modified: trunk/numpy/linalg/tests/test_linalg.py
===================================================================
--- trunk/numpy/linalg/tests/test_linalg.py	2008-04-27 18:19:12 UTC (rev 5103)
+++ trunk/numpy/linalg/tests/test_linalg.py	2008-04-27 18:44:47 UTC (rev 5104)
@@ -144,7 +144,7 @@
         x, residuals, rank, sv = linalg.lstsq(a, b)
         assert_almost_equal(b, dot(a, x))
         assert_equal(rank, asarray(a).shape[0])
-        assert_almost_equal(sv, s)
+        assert_almost_equal(sv, sv.__array_wrap__(s))
         assert imply(isinstance(b, matrix), isinstance(x, matrix))
         assert imply(isinstance(b, matrix), isinstance(residuals, matrix))
         assert imply(isinstance(b, matrix), isinstance(sv, matrix))



More information about the Numpy-svn mailing list