[Scipy-svn] r3945 - in trunk/scipy/sparse: . tests

scipy-svn@scip... scipy-svn@scip...
Sat Feb 16 13:53:26 CST 2008


Author: wnbell
Date: 2008-02-16 13:53:19 -0600 (Sat, 16 Feb 2008)
New Revision: 3945

Modified:
   trunk/scipy/sparse/data.py
   trunk/scipy/sparse/tests/test_base.py
Log:
fixed .real and .imag errors
resolves ticket #606


Modified: trunk/scipy/sparse/data.py
===================================================================
--- trunk/scipy/sparse/data.py	2008-02-16 13:46:34 UTC (rev 3944)
+++ trunk/scipy/sparse/data.py	2008-02-16 19:53:19 UTC (rev 3945)
@@ -27,10 +27,10 @@
         return self._with_data(abs(self.data))
 
     def _real(self):
-        return self._with_data(numpy.real(self.data),copy=False)
+        return self._with_data(self.data.real)
 
     def _imag(self):
-        return self._with_data(numpy.imag(self.data),copy=False)
+        return self._with_data(self.data.imag)
     
     def __neg__(self):
         return self._with_data(-self.data)

Modified: trunk/scipy/sparse/tests/test_base.py
===================================================================
--- trunk/scipy/sparse/tests/test_base.py	2008-02-16 13:46:34 UTC (rev 3944)
+++ trunk/scipy/sparse/tests/test_base.py	2008-02-16 19:53:19 UTC (rev 3945)
@@ -75,6 +75,15 @@
         A = matrix([[-1, 0, 17],[0, -5, 0],[1, -4, 0],[0,0,0]],'d')
         assert_equal(-A,(-self.spmatrix(A)).todense())
 
+    def test_real(self):
+        D = matrix([[1 + 3j, 2 - 4j]])
+        A = self.spmatrix(D)
+        assert_equal(A.real.todense(),D.real)
+    
+    def test_imag(self):
+        D = matrix([[1 + 3j, 2 - 4j]])
+        A = self.spmatrix(D)
+        assert_equal(A.imag.todense(),D.imag)
 
     def test_diagonal(self):
         """Does the matrix's .diagonal() method work?



More information about the Scipy-svn mailing list