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

2009-07-10 Thread David Goldsmith
Touche. DG --- On Fri, 7/10/09, David Warde-Farley wrote: > From: David Warde-Farley > Subject: Re: [Numpy-discussion] an np.arange for arrays? > To: "Discussion of Numerical Python" > Date: Friday, July 10, 2009, 1:06 PM > On 10-Jul-09, at 1:26 PM, David >

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

2009-07-10 Thread David Warde-Farley
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 [3

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

2009-07-10 Thread David Goldsmith
11., 12., 13., 14.], [ 7., 8., 9., 10., 11., 12., 13., 14., 15.], [ 8., 9., 10., 11., 12., 13., 14., 15., 16.], [ 9., 10., 11., 12., 13., 14., 15., 16., 17.], [ 10., 11., 12., 13., 14., 15., 16., 17., 18.]]) DG --- On Fri, 7/10/0

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

2009-07-10 Thread Chris Colbert
Oh cool, I couldn't figure out with mgrid. here's what ended up with using broadcasting: >>> import numpy as np >>> X = np.zeros((10)) >>> Y = np.arange(10, 20) >>> M = 10 >>> increments = np.arange(1, M+1) >>> delta = Y - X >>> dl = (delta / M).reshape(-1, 1) >>> interps = dl * increments >>> lin

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

2009-07-10 Thread David Warde-Farley
On 10-Jul-09, at 1:25 AM, Chris Colbert wrote: > actually what would be better is if i can pass two 1d arrays X and Y > both size Nx1 > and get back a 2d array of size NxM where the [n,:] row is the linear > interpolation of X[n] to Y[n] This could be more efficient, but here's a solution using

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

2009-07-09 Thread Chris Colbert
actually what would be better is if i can pass two 1d arrays X and Y both size Nx1 and get back a 2d array of size NxM where the [n,:] row is the linear interpolation of X[n] to Y[n] On Fri, Jul 10, 2009 at 1:16 AM, Chris Colbert wrote: > If i have two arrays representing start points and end po

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

2009-07-09 Thread Chris Colbert
If i have two arrays representing start points and end points, is there a function that will return a 2d array where each row is the range(start, end, n) where n is a fixed number of steps and is the same for all rows? ___ NumPy-Discussion mailing list Nu