[Scipy-svn] r4834 - trunk/scipy/sparse

scipy-svn@scip... scipy-svn@scip...
Sat Oct 25 16:26:47 CDT 2008


Author: wnbell
Date: 2008-10-25 16:26:45 -0500 (Sat, 25 Oct 2008)
New Revision: 4834

Modified:
   trunk/scipy/sparse/coo.py
   trunk/scipy/sparse/dia.py
Log:
removed sum_duplicates option from coo_matrix.tocsr() and coo_matrix.tocsc()


Modified: trunk/scipy/sparse/coo.py
===================================================================
--- trunk/scipy/sparse/coo.py	2008-10-25 10:29:28 UTC (rev 4833)
+++ trunk/scipy/sparse/coo.py	2008-10-25 21:26:45 UTC (rev 4834)
@@ -233,12 +233,25 @@
         coo_todense(M, N, self.nnz, self.row, self.col, self.data, B.ravel() )
         return B
 
-    def tocsc(self,sum_duplicates=True):
+    def tocsc(self):
         """Return a copy of this matrix in Compressed Sparse Column format
 
-            By default sum_duplicates=True and any duplicate
-            matrix entries are added together.
+        Duplicate entries will be summed together.
 
+        Example
+        -------
+        >>> from numpy import array
+        >>> from scipy.sparse import coo_matrix
+        >>> row  = array([0,0,1,3,1,0,0])
+        >>> col  = array([0,2,1,3,1,0,0])
+        >>> data = array([1,1,1,1,1,1,1])
+        >>> A = coo_matrix( (data,(row,col)), shape=(4,4)).tocsc()
+        >>> A.todense()
+        matrix([[3, 0, 1, 0],
+                [0, 2, 0, 0],
+                [0, 0, 0, 0],
+                [0, 0, 0, 1]])
+
         """
         from csc import csc_matrix
         if self.nnz == 0:
@@ -253,16 +266,28 @@
                       indptr, indices, data)
 
             A = csc_matrix((data, indices, indptr), self.shape)
-            if sum_duplicates:
-                A.sum_duplicates()
+            A.sum_duplicates()
             return A
 
-    def tocsr(self,sum_duplicates=True):
+    def tocsr(self):
         """Return a copy of this matrix in Compressed Sparse Row format
 
-            By default sum_duplicates=True and any duplicate
-            matrix entries are added together.
+        Duplicate entries will be summed together.
 
+        Example
+        -------
+        >>> from numpy import array
+        >>> from scipy.sparse import coo_matrix
+        >>> row  = array([0,0,1,3,1,0,0])
+        >>> col  = array([0,2,1,3,1,0,0])
+        >>> data = array([1,1,1,1,1,1,1])
+        >>> A = coo_matrix( (data,(row,col)), shape=(4,4)).tocsr()
+        >>> A.todense()
+        matrix([[3, 0, 1, 0],
+                [0, 2, 0, 0],
+                [0, 0, 0, 0],
+                [0, 0, 0, 1]])
+
         """
         from csr import csr_matrix
         if self.nnz == 0:
@@ -277,8 +302,7 @@
                       indptr, indices, data)
 
             A = csr_matrix((data, indices, indptr), self.shape)
-            if sum_duplicates:
-                A.sum_duplicates()
+            A.sum_duplicates()
             return A
 
 

Modified: trunk/scipy/sparse/dia.py
===================================================================
--- trunk/scipy/sparse/dia.py	2008-10-25 10:29:28 UTC (rev 4833)
+++ trunk/scipy/sparse/dia.py	2008-10-25 21:26:45 UTC (rev 4834)
@@ -164,11 +164,11 @@
 
     def tocsr(self):
         #this could be faster
-        return self.tocoo().tocsr(sum_duplicates=False)
+        return self.tocoo().tocsr()
 
     def tocsc(self):
         #this could be faster
-        return self.tocoo().tocsc(sum_duplicates=False)
+        return self.tocoo().tocsc()
 
     def tocoo(self):
         num_data = len(self.data)



More information about the Scipy-svn mailing list