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

numpy-svn at scipy.org numpy-svn at scipy.org
Fri Jul 14 05:42:56 EDT 2006


Author: cookedm
Date: 2006-07-14 04:42:54 -0500 (Fri, 14 Jul 2006)
New Revision: 2821

Modified:
   trunk/numpy/linalg/linalg.py
   trunk/numpy/linalg/tests/test_linalg.py
Log:
numpy.linalg: fix bug where complex arrays weren't being returned.
Also improved test cases.


Modified: trunk/numpy/linalg/linalg.py
===================================================================
--- trunk/numpy/linalg/linalg.py	2006-07-14 08:05:55 UTC (rev 2820)
+++ trunk/numpy/linalg/linalg.py	2006-07-14 09:42:54 UTC (rev 2821)
@@ -18,7 +18,8 @@
 from numpy.core import array, asarray, zeros, empty, transpose, \
         intc, single, double, csingle, cdouble, inexact, complexfloating, \
         newaxis, ravel, all, Inf, dot, add, multiply, identity, sqrt, \
-        maximum, nonzero, diagonal, arange, fastCopyAndTranspose, sum
+        maximum, nonzero, diagonal, arange, fastCopyAndTranspose, sum, \
+        argsort
 from numpy.lib import triu
 from numpy.linalg import lapack_lite
 
@@ -75,7 +76,7 @@
         result_type = _complex_types_map[result_type]
     else:
         t = double
-    return t, rt
+    return t, result_type
 
 def _castCopyAndTranspose(type, *arrays):
     if len(arrays) == 1:
@@ -351,7 +352,7 @@
     if results['info'] > 0:
         raise LinAlgError, 'Eigenvalues did not converge'
     at = a.transpose().astype(result_t)
-    return w.astype(result_t), wrap(at)
+    return w.astype(_realType(result_t)), wrap(at)
 
 
 # Singular value decomposition

Modified: trunk/numpy/linalg/tests/test_linalg.py
===================================================================
--- trunk/numpy/linalg/tests/test_linalg.py	2006-07-14 08:05:55 UTC (rev 2820)
+++ trunk/numpy/linalg/tests/test_linalg.py	2006-07-14 09:42:54 UTC (rev 2821)
@@ -17,19 +17,25 @@
     old_assert_almost_equal(a, b, decimal=decimal, **kw)
 
 class LinalgTestCase(NumpyTestCase):
-    def _check(self, dtype):
-        a = array([[1.,2.], [3.,4.]], dtype=dtype)
-        b = array([2., 1.], dtype=dtype)
+    def check_single(self):
+        a = array([[1.,2.], [3.,4.]], dtype=single)
+        b = array([2., 1.], dtype=single)
         self.do(a, b)
 
-    def check_single(self):
-        self._check(single)
     def check_double(self):
-        self._check(double)
+        a = array([[1.,2.], [3.,4.]], dtype=double)
+        b = array([2., 1.], dtype=double)
+        self.do(a, b)
+
     def check_csingle(self):
-        self._check(csingle)
+        a = array([[1.+2j,2+3j], [3+4j,4+5j]], dtype=csingle)
+        b = array([2.+1j, 1.+2j], dtype=csingle)
+        self.do(a, b)
+
     def check_cdouble(self):
-        self._check(cdouble)
+        a = array([[1.+2j,2+3j], [3+4j,4+5j]], dtype=cdouble)
+        b = array([2.+1j, 1.+2j], dtype=cdouble)
+        self.do(a, b)
 
 class test_solve(LinalgTestCase):
     def do(self, a, b):




More information about the Numpy-svn mailing list