[Numpy-discussion] Slicing/selection in multiple dimensions simultaneously

Stéfan van der Walt stefan@sun.ac...
Tue Mar 3 03:11:19 CST 2009


Hi Robert

2009/2/27 Robert Kern <robert.kern@gmail.com>:
>> a[ix_([2,3,6],range(a.shape[1]),[3,2])]
>>
>> If anyone knows a better way?
>
> One could probably make ix_() take slice objects, too, to generate the
> correct arange() in the appropriate place.

I was wondering how one would implement this, since the ix_ function
has no knowledge of the dimensions of "a".

The best I could do was to allow

a[ix_[[2,3,6], :3, [3, 2]]

to work (see attached patch).

Cheers
Stéfan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Allow-fully-specified-ranges-in-ix_.patch
Type: text/x-diff
Size: 3516 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20090303/40c465c6/attachment-0001.bin 


More information about the Numpy-discussion mailing list