[Numpy-discussion] Re: Silly array question

Robert Kern robert.kern at gmail.com
Fri Apr 7 15:39:02 EDT 2006


Christopher Barker wrote:
> Sasha wrote:
> 
>> One more obfuscated numpy entry:
>>
>>>>> M[tuple(transpose(I))]
>>
>> array([ 1,  6, 11,  6])
> 
> exactly. Can anyone explain why that works, but:
> 
> M[transpose(I)]
> 
> or
> M[I]
> 
> doesn't?

There's some typechecking going on in __getitem__. Tuples are presumed to mean
that each item in the tuple is indexing on a different axis. Non-tuples are
presumed to be fancy array-indexing.

-- 
Robert Kern
robert.kern at gmail.com

"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 mailing list