[Numpy-discussion] use slicing as argument values?

Chao YUE chaoyuejoy@gmail....
Fri Jul 13 07:07:54 CDT 2012

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
retrieve data from variables

actually I can also put the [var1,var2,var3,var4,var5] as arguments in the
plot_eg function so that I can pick any variables I want to plot as long as
they have the same dimension. otherwise, I have to change the index_range
for every variable.



2012/7/13 Daniele Nicolodi <daniele@grinta.net>

> 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 close now.
> I don't see the advantage of this approach over directly using the
> sliced array as an argument of your function, as in func(a[1:3,:,4]).
> Can you elaborate more why you are going through this route?
> Cheers,
> Daniele
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120713/b0852c16/attachment.html 

More information about the NumPy-Discussion mailing list