[Scipy-svn] r3635 - trunk/scipy/sparse
scipy-svn at scipy.org
scipy-svn at scipy.org
Tue Dec 11 02:46:51 EST 2007
Author: wnbell
Date: 2007-12-11 01:46:48 -0600 (Tue, 11 Dec 2007)
New Revision: 3635
Modified:
trunk/scipy/sparse/sparse.py
Log:
change to coo_matrix.todok()
should fix ticket #555
Modified: trunk/scipy/sparse/sparse.py
===================================================================
--- trunk/scipy/sparse/sparse.py 2007-12-11 05:15:05 UTC (rev 3634)
+++ trunk/scipy/sparse/sparse.py 2007-12-11 07:46:48 UTC (rev 3635)
@@ -1412,8 +1412,6 @@
" integers"
self.shape = A
elif isspmatrix(A):
- # For sparse matrices, this is too inefficient; we need
- # something else.
if isspmatrix_dok(A) and copy:
A = A.copy()
else:
@@ -2120,7 +2118,15 @@
def todok(self):
dok = dok_matrix((self.shape),dtype=self.dtype)
- dok.update( zip(zip(self.row,self.col),self.data) )
+
+ try:
+ izip = itertools.izip
+ dok.update( izip(izip(self.row,self.col),self.data) )
+ except AttributeError:
+ # the dict() call is for Python 2.3 compatibility
+ # ideally dok_matrix would accept an iterator
+ dok.update( dict( zip(zip(self.row,self.col),self.data) ) )
+
return dok
More information about the Scipy-svn
mailing list