[Numpy-discussion] indexing bug?

Christopher Barker Chris.Barker at noaa.gov
Wed Oct 3 13:52:58 EDT 2007


Stefan van der Walt wrote:
>> The current behavior is consistent and well
>>> defined:
>>> a[x] == a[int(x)]

This is all possible because of PEP 357:

http://www.python.org/dev/peps/pep-0357/

However, when I read this from the PEP:

"""
It is not possible to use the nb_int (and __int__ special method)
for this purpose because that method is used to *coerce* objects
to integers.  It would be inappropriate to allow every object that
can be coerced to an integer to be used as an integer everywhere
Python expects a true integer.  For example, if __int__ were used
to convert an object to an integer in slicing, then float objects
would be allowed in slicing and x[3.2:5.8] would not raise an error
as it should.
"""

It seems pretty clear that only integer types were intended to by used 
as indexes. Does that make this a bug? I'll defer that to others more in 
the know than I.

-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov



More information about the NumPy-Discussion mailing list