[Numpy-discussion] indexing question

John Salvatier jsalvati at u.washington.edu
Mon Nov 22 15:32:45 EST 2010


I think that the only speedup you will get is defining an index only
once and reusing it.

2010/11/22 Ernest Adrogué <eadrogue at gmx.net>:
> 22/11/10 @ 14:04 (-0600), thus spake Robert Kern:
>> > This way, I get the elements (0,1) and (1,1) which is what
>> > I wanted. The question is: is it possible to omit the [0,1]
>> > in the index?
>>
>> No, but you can write generic code for it:
>>
>>   t[np.arange(t.shape[0]), x, y]
>
> Thank you. This is what I wanted to know.
>
> --
> Ernest
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>



More information about the NumPy-Discussion mailing list