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

scipy-svn@scip... scipy-svn@scip...
Thu Apr 24 19:26:07 CDT 2008


Author: wnbell
Date: 2008-04-24 19:26:05 -0500 (Thu, 24 Apr 2008)
New Revision: 4176

Modified:
   trunk/scipy/sparse/base.py
   trunk/scipy/sparse/tests/test_base.py
Log:
fix getrow/getcol error
added unittests


Modified: trunk/scipy/sparse/base.py
===================================================================
--- trunk/scipy/sparse/base.py	2008-04-25 00:11:33 UTC (rev 4175)
+++ trunk/scipy/sparse/base.py	2008-04-25 00:26:05 UTC (rev 4176)
@@ -341,6 +341,7 @@
         # Spmatrix subclasses should override this method for efficiency.
         # Post-multiply by a (n x 1) column vector 'a' containing all zeros
         # except for a_j = 1
+        from csc import csc_matrix
         n = self.shape[1]
         a = csc_matrix((n, 1), dtype=self.dtype)
         a[j, 0] = 1
@@ -353,6 +354,7 @@
         # Spmatrix subclasses should override this method for efficiency.
         # Pre-multiply by a (1 x m) row vector 'a' containing all zeros
         # except for a_i = 1
+        from csr import csr_matrix
         m = self.shape[0]
         a = csr_matrix((1, m), dtype=self.dtype)
         a[0, i] = 1

Modified: trunk/scipy/sparse/tests/test_base.py
===================================================================
--- trunk/scipy/sparse/tests/test_base.py	2008-04-25 00:11:33 UTC (rev 4175)
+++ trunk/scipy/sparse/tests/test_base.py	2008-04-25 00:26:05 UTC (rev 4176)
@@ -104,6 +104,13 @@
         for m in mats:
             assert_equal(self.spmatrix(m).diagonal(),diag(m))
 
+
+    def test_getrow(self):
+        assert_array_equal(self.datsp.getrow(1).todense(), self.dat[1,:])
+    
+    def test_getcol(self):
+        assert_array_equal(self.datsp.getcol(1).todense(), self.dat[:,1])
+
     def test_sum(self):
         """Does the matrix's .sum(axis=...) method work?
         """



More information about the Scipy-svn mailing list