[Numpy-discussion] Getting an item in an array with its coordinates given by another array

Matthieu Brucher matthieu.brucher@gmail....
Sun Oct 28 09:59:20 CDT 2007


Little correction, only c[(2,3)] gives me what I expect, not c[[2,3]], which
is even stranger.

2007/10/28, Matthieu Brucher <matthieu.brucher@gmail.com>:
>
> Hi,
>
> I'm trying to get an item in an array when I only have another array
> giving the position.
>
> For instance:
>
> >>> c = numpy.arange(0., 3*4*5).reshape((3,4,5))
> >>> c***(numpy.array ((2,3), dtype=int))
> [55, 56, 57, 58, 59]
>
> I'm trying to figure what to put between c and ((2,3)). I supposed that
> the take method would be what I wanted but it is not... The [] operator does
> not work on array(but it seems to give the expected result with a tuple or a
> list). Is there a method for this ?
>
> Matthieu
>
> --
> French PhD student
> Website : http://miles.developpez.com/
> Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92




-- 
French PhD student
Website : http://miles.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20071028/51dc5f6b/attachment.html 


More information about the Numpy-discussion mailing list