[Scipy-svn] r3188 - trunk/Lib/sparse

scipy-svn@scip... scipy-svn@scip...
Wed Jul 25 00:46:23 CDT 2007


Author: wnbell
Date: 2007-07-25 00:46:18 -0500 (Wed, 25 Jul 2007)
New Revision: 3188

Modified:
   trunk/Lib/sparse/sparse.py
Log:
added __all__ to sparse.py to avoid polluting namespace



Modified: trunk/Lib/sparse/sparse.py
===================================================================
--- trunk/Lib/sparse/sparse.py	2007-07-24 14:13:43 UTC (rev 3187)
+++ trunk/Lib/sparse/sparse.py	2007-07-25 05:46:18 UTC (rev 3188)
@@ -4,6 +4,13 @@
 Modified and extended by Ed Schofield, Robert Cimrman, and Nathan Bell
 """
 
+
+__all__ = ['csc_matrix','csr_matrix','coo_matrix','lil_matrix','dok_matrix', 
+            'spdiags','speye','spidentity', 
+            'isspmatrix','issparse','isspmatrix_csc','isspmatrix_csr',
+            'isspmatrix_lil','isspmatrix_dok' ]
+                        
+
 import warnings
 
 from numpy import zeros, isscalar, real, imag, asarray, asmatrix, matrix, \
@@ -2104,7 +2111,7 @@
             indptr, rowind, data = cootocsc(self.shape[0], self.shape[1], \
                                             self.size, self.row, self.col, \
                                             self.data)
-            return csc_matrix((data, rowind, indptr), self.shape)
+            return csc_matrix((data, rowind, indptr), self.shape, check=False)
 
     
     def tocsr(self):
@@ -2114,7 +2121,7 @@
             indptr, colind, data = cootocsr(self.shape[0], self.shape[1], \
                                             self.size, self.row, self.col, \
                                             self.data)        
-            return csr_matrix((data, colind, indptr), self.shape)
+            return csr_matrix((data, colind, indptr), self.shape, check=False)
             
     def tocoo(self, copy=False):
         return self.toself(copy)
@@ -2600,48 +2607,3 @@
     return isinstance(t, (list, tuple))
 
 
-def _testme():
-    a = csc_matrix((arange(1, 9), \
-            transpose([[0, 1, 1, 2, 2, 3, 3, 4], [0, 1, 3, 0, 2, 3, 4, 4]])))
-    print "Representation of a matrix:"
-    print repr(a)
-    print "How a matrix prints:"
-    print a
-    print "Adding two matrices:"
-    b = a+a
-    print b
-    print "Subtracting two matrices:"
-    c = b - a
-    print c
-    print "Multiplying a sparse matrix by a dense vector:"
-    d = a*[1, 2, 3, 4, 5]
-    print d
-    print [1, 2, 3, 4, 5]*a
-
-    print "Inverting a sparse linear system:"
-    print "The sparse matrix (constructed from diagonals):"
-    a = spdiags([[1, 2, 3, 4, 5], [6, 5, 8, 9, 10]], [0, 1], 5, 5)
-    b = array([1, 2, 3, 4, 5])
-    
-    print "(Various small tests follow ...)\n"
-    print "Dictionary of keys matrix:"
-    a = dok_matrix(shape=(10, 10))
-    a[1, 1] = 1.
-    a[1, 5] = 1.
-    print a
-    print "Adding it to itself:"
-    print a + a
-
-    print "Multiplying by a scalar:"
-    print a * 100
-
-    print "Dense representation:"
-    print a.todense()
-
-    print "Converting to a CSR matrix:"
-    c = a.tocsr()
-    print c
-
-if __name__ == "__main__":
-    _testme()
-



More information about the Scipy-svn mailing list