[Numpy-discussion] use slicing as argument values?

Matthew Brett matthew.brett@gmail....
Fri Jul 13 16:30:50 CDT 2012


On Fri, Jul 13, 2012 at 9:24 AM, Robert Kern <robert.kern@gmail.com> wrote:
> On Thu, Jul 12, 2012 at 10:32 PM, Chao YUE <chaoyuejoy@gmail.com> wrote:
>> Thanks all for the discussion. Actually I am trying to use something like
>> numpy ndarray indexing in the function. Like when I call:
>>
>> func(a,'1:3,:,2:4'), it knows I want to retrieve a[1:3,:,2:4], and
>> func(a,'1:3,:,4') for a[1:3,:,4] ect.
>> I am very close now.
>
> [~]
> |1> from numpy import index_exp
>
> [~]
> |2> index_exp[1:3,:,2:4]
> (slice(1, 3, None), slice(None, None, None), slice(2, 4, None))

Nice - thanks for the pointer,

Matthew


More information about the NumPy-Discussion mailing list