[Numpy-discussion] Help w/ indexing, please
David Goldsmith
d.l.goldsmith at gmail.com
Tue Jul 27 14:19:39 EDT 2010
On Tue, Jul 27, 2010 at 9:32 AM, John Salvatier
<jsalvati at u.washington.edu>wrote:
> I am pretty sure you should be able to do
>
> R = C[L, :] and get the array you want.
>
> Try it with a small matrix where you know the result you want. You may
> need to transpose some axes afterwards, but I don't think you should.
>
Thanks, John, that works; you may be right about the transposing, but I can
work that out empirically. Thanks again!
DG
>
> On Tue, Jul 27, 2010 at 9:10 AM, David Goldsmith <d.l.goldsmith at gmail.com>wrote:
>
>> Hi! I have a large M x K, M, K ~ 1e3 array L of indices - non-negative
>> integers in the range 0 to N-1 - and an N x 3 array C (a matplotlib
>> colormap). I need to create an M x K x 3 array R such that R[m,k,j] =
>> C[L[m,k], j], j = 0,1,2. I want to do so w/out having to loop through all
>> the (m,k) index pairs, but I'm having trouble wrapping my brain around how
>> to do it - please help. Thanks.
>>
>> DG
>>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion at scipy.org
>> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
>>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
--
Mathematician: noun, someone who disavows certainty when their uncertainty
set is non-empty, even if that set has measure zero.
Hope: noun, that delusive spirit which escaped Pandora's jar and, with her
lies, prevents mankind from committing a general suicide. (As interpreted
by Robert Graves)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100727/e68764db/attachment.html>
More information about the NumPy-Discussion
mailing list