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

scipy-svn at scipy.org scipy-svn at scipy.org
Tue Dec 5 14:32:08 EST 2006


Author: edschofield
Date: 2006-12-05 13:32:01 -0600 (Tue, 05 Dec 2006)
New Revision: 2352

Modified:
   trunk/Lib/sparse/sparse.py
Log:
Applied Neilen Marais's patch for non-machine-size int indices in sparse.lil_matrix (ticket #307)


Modified: trunk/Lib/sparse/sparse.py
===================================================================
--- trunk/Lib/sparse/sparse.py	2006-12-04 04:46:41 UTC (rev 2351)
+++ trunk/Lib/sparse/sparse.py	2006-12-05 19:32:01 UTC (rev 2352)
@@ -2445,6 +2445,7 @@
             raise IndexError, "lil_matrix supports slices only of a single row"
             # TODO: add support for this, like in __setitem__
         elif isintlike(i):
+            i = int(i)   # Python list indices must be machine-sized ints
             if not (i>=0 and i<self.shape[0]):
                 raise IndexError, "lil_matrix index out of range"
         elif operator.isSequenceType(i):
@@ -2470,6 +2471,7 @@
         elif operator.isSequenceType(j):
             raise NotImplementedError, "sequence indexing not yet fully supported"
         elif isintlike(j):
+            j = int(j)   # Python list indices must be machine-sized ints
             if not (j>=0 and j<self.shape[1]):
                 raise IndexError, "lil_matrix index out of range"
         else:
@@ -2489,6 +2491,7 @@
             raise IndexError, "invalid index"
         i, j = index
         if isintlike(i):
+            i = int(i)   # Python list indices must be machine-sized ints
             if not (i>=0 and i<self.shape[0]):
                 raise IndexError, "lil_matrix index out of range"
         else:
@@ -2518,6 +2521,7 @@
         # Below here, i is an integer
         row = self.rows[i]
         if isintlike(j):
+            j = int(j)   # Python list indices must be machine-sized ints
             if not (j>=0 and j<self.shape[1]):
                 raise IndexError, "lil_matrix index out of range"
             # Find element to be set or removed




More information about the Scipy-svn mailing list