[Numpy-discussion] an np.arange for arrays?

David Goldsmith d_l_goldsmith at yahoo.com
Fri Jul 10 16:35:25 EDT 2009


Touche.

DG

--- On Fri, 7/10/09, David Warde-Farley <dwf at cs.toronto.edu> wrote:

> From: David Warde-Farley <dwf at cs.toronto.edu>
> Subject: Re: [Numpy-discussion] an np.arange for arrays?
> To: "Discussion of Numerical Python" <numpy-discussion at scipy.org>
> Date: Friday, July 10, 2009, 1:06 PM
> On 10-Jul-09, at 1:26 PM, David
> Goldsmith wrote:
> 
> > grid = np.array([np.linspace(x[i],y[i],nrows) for i
> in  
> > range(len(x))]).T
> 
> Indeed, linspace will work, but careful with Python loops
> though,  
> it'll be 2x to 6x slower (based on my empirical fiddling)
> than the  
> solution involving mgrid.
> 
> In [31]: X = arange(10); Y = arange(10)+1
> In [32]: timeit grid = np.array([np.linspace(X[i],Y[i],20)
> for i in  
> range(len(X))]).T
> 1000 loops, best of 3: 424 us per loop
> 
> In [33]: timeit interp_grid_thingie(X, Y, 20)
> 10000 loops, best of 3: 79.9 us per loop
> 
> David
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> 


      



More information about the NumPy-Discussion mailing list