Re: [Numpy-discussion] use slicing as argument values?

2012-07-13 Thread Matthew Brett
On Fri, Jul 13, 2012 at 9:24 AM, Robert Kern wrote: > On Thu, Jul 12, 2012 at 10:32 PM, Chao YUE 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

Re: [Numpy-discussion] use slicing as argument values?

2012-07-13 Thread Chao YUE
Thanks Robert. This is exactly what I want. I have a feeling that there must be something in numpy that can do the job and I didn't know. Thanks again, Chao 2012/7/13 Robert Kern > On Thu, Jul 12, 2012 at 10:32 PM, Chao YUE wrote: > > Thanks all for the discussion. Actually I am trying to use

Re: [Numpy-discussion] use slicing as argument values?

2012-07-13 Thread Robert Kern
On Thu, Jul 12, 2012 at 10:32 PM, Chao YUE 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. >

Re: [Numpy-discussion] use slicing as argument values?

2012-07-13 Thread Chris Barker
On Thu, Jul 12, 2012 at 2:32 PM, Chao YUE wrote: > 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. why do the string packing/unpacking? why not use an interface much like the

Re: [Numpy-discussion] use slicing as argument values?

2012-07-13 Thread Chao YUE
Thanks Daniele. I am writing a small plotting function that can receive the index range as argument value. like I have variables var1, var2, var3, var4, var5 which have exactly the same dimensions. def plot_eg(index_range): #here I need the function above which can use the index_range to re

Re: [Numpy-discussion] use slicing as argument values?

2012-07-13 Thread Daniele Nicolodi
On 12/07/2012 23:32, Chao YUE 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 clo

Re: [Numpy-discussion] use slicing as argument values?

2012-07-13 Thread Pauli Virtanen
Benjamin Root ou.edu> writes: [clip] > a[sl] and a[3:5, 5:14] is equivalent to > sl = (slice(3, 5), slice(5, 14)) > a[sl] [clip] which is also equivalent to sl = np.s_[3:5, 5:14] ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http:

Re: [Numpy-discussion] use slicing as argument values?

2012-07-12 Thread Benjamin Root
On Thursday, July 12, 2012, Chao YUE 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

Re: [Numpy-discussion] use slicing as argument values?

2012-07-12 Thread Chao YUE
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. #so this function changes the string to

Re: [Numpy-discussion] use slicing as argument values?

2012-07-12 Thread Benjamin Root
On Thu, Jul 12, 2012 at 4:46 PM, Chao YUE wrote: > Hi Ben, > > it helps a lot. I am nearly finishing a function in a way I think > pythonic. > Just one more question, I have: > > In [24]: b=np.arange(1,11) > > In [25]: b > Out[25]: array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) > > In [26]: b[sl

Re: [Numpy-discussion] use slicing as argument values?

2012-07-12 Thread Jonathan Helmus
On 07/12/2012 04:46 PM, Chao YUE wrote: > Hi Ben, > > it helps a lot. I am nearly finishing a function in a way I think > pythonic. > Just one more question, I have: > > In [24]: b=np.arange(1,11) > > In [25]: b > Out[25]: array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) > > In [26]: b[slice(1)] >

Re: [Numpy-discussion] use slicing as argument values?

2012-07-12 Thread Robert Kern
On Thu, Jul 12, 2012 at 9:46 PM, Chao YUE wrote: > Hi Ben, > > it helps a lot. I am nearly finishing a function in a way I think pythonic. > Just one more question, I have: > > In [24]: b=np.arange(1,11) > > In [25]: b > Out[25]: array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) > > In [26]: b[slice

Re: [Numpy-discussion] use slicing as argument values?

2012-07-12 Thread Chao YUE
Hi Ben, it helps a lot. I am nearly finishing a function in a way I think pythonic. Just one more question, I have: In [24]: b=np.arange(1,11) In [25]: b Out[25]: array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) In [26]: b[slice(1)] Out[26]: array([1]) In [27]: b[slice(4)] Out[27]: array([1, 2,

Re: [Numpy-discussion] use slicing as argument values?

2012-07-12 Thread Benjamin Root
On Thu, Jul 12, 2012 at 3:38 PM, Chao YUE wrote: > Dear all, > > I want to create a function and I would like one of the arguments of the > function to determine what slicing of numpy array I want to use. > a simple example: > > a=np.arange(100).reshape(10,10) > > suppose I want to have a imaging

[Numpy-discussion] use slicing as argument values?

2012-07-12 Thread Chao YUE
Dear all, I want to create a function and I would like one of the arguments of the function to determine what slicing of numpy array I want to use. a simple example: a=np.arange(100).reshape(10,10) suppose I want to have a imaging function to show image of part of this data: def show_part_of_da