[Scipy-svn] r4294 - in trunk/scipy/sparse: . tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Mon May 12 16:16:08 EDT 2008
Author: wnbell
Date: 2008-05-12 15:15:50 -0500 (Mon, 12 May 2008)
New Revision: 4294
Modified:
trunk/scipy/sparse/csr.py
trunk/scipy/sparse/tests/test_base.py
Log:
fixed indexing bug reported by Robert Cimrman
http://thread.gmane.org/gmane.comp.python.scientific.devel/7986
Modified: trunk/scipy/sparse/csr.py
===================================================================
--- trunk/scipy/sparse/csr.py 2008-05-12 16:01:32 UTC (rev 4293)
+++ trunk/scipy/sparse/csr.py 2008-05-12 20:15:50 UTC (rev 4294)
@@ -363,7 +363,8 @@
check_bounds( j0, j1, N )
indptr, indices, data = get_csr_submatrix( M, N, \
- self.indptr, self.indices, self.data, i0, i1, j0, j1 )
+ self.indptr, self.indices, self.data, \
+ int(i0), int(i1), int(j0), int(j1) )
shape = (i1 - i0, j1 - j0)
Modified: trunk/scipy/sparse/tests/test_base.py
===================================================================
--- trunk/scipy/sparse/tests/test_base.py 2008-05-12 16:01:32 UTC (rev 4293)
+++ trunk/scipy/sparse/tests/test_base.py 2008-05-12 20:15:50 UTC (rev 4294)
@@ -679,6 +679,13 @@
assert_equal(A[:,2].todense(),B[:,2])
assert_equal(A[3:4,9].todense(),B[3:4,9])
assert_equal(A[1:4,-5].todense(),B[1:4,-5])
+ assert_equal(A[2:-1,3].todense(),B[2:-1,3])
+
+ # [1:2,1:2]
+ assert_equal(A[1:2,1:2].todense(),B[1:2,1:2])
+ assert_equal(A[4:,3:].todense(),B[4:,3:])
+ assert_equal(A[:4,:5].todense(),B[:4,:5])
+ assert_equal(A[2:-1,:5].todense(),B[2:-1,:5])
# [1:2,[1,2]]
assert_equal(A[:,[2,8,3,-1]].todense(),B[:,[2,8,3,-1]])
@@ -721,6 +728,13 @@
assert_equal(A[:,[1,3]][[2,4],:].todense(), B[:,[1,3]][[2,4],:] )
assert_equal(A[:,[-1,-3]][[2,-4],:].todense(), B[:,[-1,-3]][[2,-4],:] )
+
+ # Check bug reported by Robert Cimrman:
+ # http://thread.gmane.org/gmane.comp.python.scientific.devel/7986
+ s = slice(numpy.int8(2),numpy.int8(4),None)
+ assert_equal(A[s,:].todense(), B[2:4,:])
+ assert_equal(A[:,s].todense(), B[:,2:4])
+
class _TestArithmetic:
"""
Test real/complex arithmetic
More information about the Scipy-svn
mailing list