[Numpy-discussion] indexing bug?

Nadia Dencheva dencheva at stsci.edu
Fri Sep 28 15:07:30 EDT 2007


This should return an error and not silently truncate to int.

Nadia

Lou Pecora wrote:
> Looks like it truncates to an int.  But I wouldn't do
> it especially if you use floating operations (+,*,/,
> etc.) since what you get may not truncate to the
> integer you expect.  Remember floats are approximate
> representations for many rational numbers.  Stick with
> integers, IMHO.
> 
> --- Nadia Dencheva <dencheva at stsci.edu> wrote:
> 
>> Is indexing with floats really allowed in numpy?
>>
>>
>>  >>> a=numpy.array([1,2,3,4])
>>  >>> a[2.99]
>> 3
> 
> 
> 
> -- Lou Pecora,   my views are my own.
> 
> 
>        
> ____________________________________________________________________________________
> Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out.
> http://answers.yahoo.com/dir/?link=list&sid=396545469
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion



More information about the NumPy-Discussion mailing list