[Numpy-discussion] Python scalar float indices into array work - but not for array indices - why ?
Wed Nov 17 13:15:44 CST 2010
On Wed, Nov 17, 2010 at 13:11, Sebastian Haase <firstname.lastname@example.org> wrote:
> On Wed, Nov 17, 2010 at 7:48 PM, Nathaniel Smith <email@example.com> wrote:
>> On Wed, Nov 17, 2010 at 10:32 AM, Sebastian Haase <firstname.lastname@example.org> wrote:
>>> On Wed, Nov 17, 2010 at 7:26 PM, Robert Kern <email@example.com> wrote:
>>>> On Wed, Nov 17, 2010 at 12:20, Sebastian Haase <firstname.lastname@example.org> wrote:
>>>>> Why does numpy not accept float arrays as indices ?
>>>>> I was very happy and quite surprised once I found out that it worked
>>>>> at all for Python float scalars,
>>>>> but would it not just be consequent to also allow float ndarrays then ?
>>>> It only works for float scalars by accident. Do not rely on it.
>>> Could you be more specific ? As a feature, it for sure can be useful.
>> I think Robert Kern has the same intuition as me: that supporting
>> float indices is pointless. So, can you give any *specific examples*
>> of things you can do with float indices that would be difficult or
>> more expensive using integer indices? That's probably the best way to
>> convince people.
>> -- Nathaniel
> suppose you have 2 vectors of floating point coordinates `x` and `y`
> and you want to do operations utilizing fancy indexing like
> image[ [x,y] ] += 1
> As I just realized, this specific case seems to be addressed by histogram2d,
> however, if float indices would work this would of course be much more
> general: higher dimensionality and not just '+=' operations.
Actually, it wouldn't work even if x and y were integers.
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion