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

numpy-svn@scip... numpy-svn@scip...
Mon Apr 28 22:05:52 CDT 2008


Author: charris
Date: 2008-04-28 22:05:50 -0500 (Mon, 28 Apr 2008)
New Revision: 5111

Modified:
   trunk/numpy/linalg/linalg.py
   trunk/numpy/linalg/tests/test_linalg.py
Log:
Keep singular values and eigenvalues as 1D arrays until the matrix indexing
controversy is settled. This will also keep code that uses diag(ev), from
breaking.


Modified: trunk/numpy/linalg/linalg.py
===================================================================
--- trunk/numpy/linalg/linalg.py	2008-04-29 00:13:25 UTC (rev 5110)
+++ trunk/numpy/linalg/linalg.py	2008-04-29 03:05:50 UTC (rev 5111)
@@ -594,7 +594,7 @@
             result_t = _complexType(result_t)
     if results['info'] > 0:
         raise LinAlgError, 'Eigenvalues did not converge'
-    return wrap(w.astype(result_t))
+    return w.astype(result_t)
 
 
 def eigvalsh(a, UPLO='L'):
@@ -673,7 +673,7 @@
                                  iwork, liwork, 0)
     if results['info'] > 0:
         raise LinAlgError, 'Eigenvalues did not converge'
-    return wrap(w.astype(result_t))
+    return w.astype(result_t)
 
 def _convertarray(a):
     t, result_t = _commonType(a)
@@ -786,7 +786,7 @@
     if results['info'] > 0:
         raise LinAlgError, 'Eigenvalues did not converge'
     vt = v.transpose().astype(result_t)
-    return wrap(w.astype(result_t)), wrap(vt)
+    return w.astype(result_t), wrap(vt)
 
 
 def eigh(a, UPLO='L'):
@@ -872,7 +872,7 @@
     if results['info'] > 0:
         raise LinAlgError, 'Eigenvalues did not converge'
     at = a.transpose().astype(result_t)
-    return wrap(w.astype(_realType(result_t))), wrap(at)
+    return w.astype(_realType(result_t)), wrap(at)
 
 
 # Singular value decomposition
@@ -979,9 +979,9 @@
     if compute_uv:
         u = u.transpose().astype(result_t)
         vt = vt.transpose().astype(result_t)
-        return wrap(u), wrap(s), wrap(vt)
+        return wrap(u), s, wrap(vt)
     else:
-        return wrap(s)
+        return s
 
 def cond(x, p=None):
     """Compute the condition number of a matrix.
@@ -1208,7 +1208,7 @@
         if results['rank'] == n and m > n:
             resids = sum((transpose(bstar)[n:,:])**2, axis=0).astype(result_t)
     st = s[:min(n, m)].copy().astype(_realType(result_t))
-    return wrap(x), wrap(resids), results['rank'], wrap(st)
+    return wrap(x), wrap(resids), results['rank'], st
 
 def norm(x, ord=None):
     """Matrix or vector norm.

Modified: trunk/numpy/linalg/tests/test_linalg.py
===================================================================
--- trunk/numpy/linalg/tests/test_linalg.py	2008-04-29 00:13:25 UTC (rev 5110)
+++ trunk/numpy/linalg/tests/test_linalg.py	2008-04-29 03:05:50 UTC (rev 5111)
@@ -88,13 +88,11 @@
         ev = linalg.eigvals(a)
         evalues, evectors = linalg.eig(a)
         assert_almost_equal(ev, evalues)
-        assert imply(isinstance(a, matrix), isinstance(ev, matrix))
 
 class TestEig(LinalgTestCase):
     def do(self, a, b):
         evalues, evectors = linalg.eig(a)
         assert_almost_equal(dot(a, evectors), multiply(evectors, evalues))
-        assert imply(isinstance(a, matrix), isinstance(evalues, matrix))
         assert imply(isinstance(a, matrix), isinstance(evectors, matrix))
 
 class TestSVD(LinalgTestCase):
@@ -102,7 +100,6 @@
         u, s, vt = linalg.svd(a, 0)
         assert_almost_equal(a, dot(multiply(u, s), vt))
         assert imply(isinstance(a, matrix), isinstance(u, matrix))
-        assert imply(isinstance(a, matrix), isinstance(s, matrix))
         assert imply(isinstance(a, matrix), isinstance(vt, matrix))
 
 class TestCondSVD(LinalgTestCase):
@@ -147,7 +144,6 @@
         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))
 
 class TestMatrixPower(ParametricTestCase):
     R90 = array([[0,1],[-1,0]])



More information about the Numpy-svn mailing list