[SciPy-user] slice question

Karl Young karl.young@ucsf....
Wed Feb 11 17:40:05 CST 2009


Thanks maestro ! (not quite as trivial as I thought it would be)
> On Wed, Feb 11, 2009 at 17:31, Karl Young <karl.young@ucsf.edu> wrote:
>   
>> Sorry for the dumb question but I did search quite a bit before
>> realizing it would only take a couple of keystrokes from an Illuminati
>> to dispel my ignorance.
>>
>> I want to slice an array as:
>>
>> A[a:b,c:d,e:f,...]
>>
>> starting with two 1d arrays containing the lower and upper slice limits:
>>
>> B = [a,c,e,...] and C = [b,d,f,...]
>>
>> and I'd like to write a general expression for this given A,B,C (i.e.
>> not specify the dimension) but I can't figure out how to turn B and C
>> into  a:b,c:d,e:f,... re indexing A - any thoughts ? Thanks
>>     
>
> A[tuple([slice(b,c) for b,c in zip(B,C)])]
>
>   



More information about the SciPy-user mailing list