[Numpy-discussion] IndexExpression bug?

Michael McNeil Forbes mforbes@physics.ubc...
Fri Jun 5 16:14:57 CDT 2009


 >>> np.array([0,1,2,3])[1:-1]
array([1, 2])

but

 >>> np.array([0,1,2,3])[np.s_[1:-1]]
array([1, 2, 3])
 >>> np.array([0,1,2,3])[np.index_exp[1:-1]]
array([1, 2, 3])

Possible fix:
class IndexExpression(object):
     ...
     def __len__(self):
         return 0

(Presently this returns sys.maxint)

Does this break anything (I can't find any coverage tests)?  If not, I  
will submit a ticket.

Michael.


More information about the Numpy-discussion mailing list