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

scipy-svn@scip... scipy-svn@scip...
Thu Feb 14 10:46:25 CST 2008


Author: wnbell
Date: 2008-02-14 10:46:23 -0600 (Thu, 14 Feb 2008)
New Revision: 3940

Modified:
   trunk/scipy/sparse/csr.py
Log:
raise IndexError instead of ValueError


Modified: trunk/scipy/sparse/csr.py
===================================================================
--- trunk/scipy/sparse/csr.py	2008-02-14 16:42:25 UTC (rev 3939)
+++ trunk/scipy/sparse/csr.py	2008-02-14 16:46:23 UTC (rev 3940)
@@ -201,11 +201,11 @@
             max_indx = indices.max()
 
             if max_indx >= N:
-                raise ValueError('index (%d) out of range' % max_indx)
+                raise IndexError('index (%d) out of range' % max_indx)
 
             min_indx = indices.min()
             if min_indx < -N:
-                raise ValueError('index (%d) out of range' % (N + min_indx))
+                raise IndexError('index (%d) out of range' % (N + min_indx))
             
             if min_indx < 0:
                 indices = indices.copy()
@@ -249,7 +249,7 @@
                     row = asindices(row)                     #[[1,2],[1,2]]
                     col = asindices(col)
                     if len(row) != len(col):
-                        raise ValueError('number of row and column indices differ')
+                        raise IndexError('number of row and column indices differ')
                     val = []
                     for i,j in zip(row,col):
                         val.append(self._get_single_element(i,j))
@@ -271,7 +271,7 @@
         if (col < 0):
             col += N
         if not (0<=row<M) or not (0<=col<N):
-            raise IndexError, "index out of bounds"
+            raise IndexError("index out of bounds")
             
         #TODO make use of sorted indices (if present)
         
@@ -296,7 +296,7 @@
             i += self.shape[0]
 
         if i < 0 or i >= self.shape[0]:
-            raise ValueError('index (%d) out of range' % i ) 
+            raise IndexError('index (%d) out of range' % i ) 
 
         start, stop, stride = cslice.indices(self.shape[1])
 
@@ -350,9 +350,9 @@
 
         def check_bounds( i0, i1, num ):
             if not (0<=i0<num) or not (0<i1<=num) or not (i0<i1):
-                raise IndexError,\
+                raise IndexError( \
                       "index out of bounds: 0<=%d<%d, 0<=%d<%d, %d<%d" %\
-                      (i0, num, i1, num, i0, i1)
+                      (i0, num, i1, num, i0, i1) )
 
         i0, i1 = process_slice( row_slice, M )
         j0, j1 = process_slice( col_slice, N )



More information about the Scipy-svn mailing list