Re: [Numpy-discussion] record arrays initialization

2012-05-03 Thread Moroney, Catherine M (388D)
> > > -- > > Message: 6 > Date: Thu, 3 May 2012 10:00:11 -0700 > From: Keith Goodman > Subject: Re: [Numpy-discussion] record arrays initialization > To: Discussion of Numerical Python > Message-ID: > > Content-Type: te

Re: [Numpy-discussion] record arrays initialization

2012-05-03 Thread Keith Goodman
On Wed, May 2, 2012 at 4:46 PM, Kevin Jacobs wrote: > The cKDTree implementation is more than 4 times faster than the brute-force > approach: > > T = scipy.spatial.cKDTree(targets) > > In [11]: %timeit foo1(element, targets)   # Brute force > 1000 loops, best of 3: 385 us per loop > > In [12]: %

Re: [Numpy-discussion] record arrays initialization

2012-05-02 Thread Aronne Merrelli
On Wed, May 2, 2012 at 6:46 PM, Kevin Jacobs wrote: > On Wed, May 2, 2012 at 7:25 PM, Aronne Merrelli > wrote: >> >> In general this is a good suggestion - I was going to mention it >> earlier - but I think for this particular problem it is not better >> than the "brute force" and argmin() NumPy

Re: [Numpy-discussion] record arrays initialization

2012-05-02 Thread Benjamin Root
On Wednesday, May 2, 2012, Stéfan van der Walt wrote: > On Wed, May 2, 2012 at 4:46 PM, Kevin Jacobs > > > > > wrote: > > A FLANN implementation should be even faster--perhaps by as much as > another > > factor of two. > > I guess it depends on whether you care about the "Approximate" in > "Fast

Re: [Numpy-discussion] record arrays initialization

2012-05-02 Thread Stéfan van der Walt
On Wed, May 2, 2012 at 4:46 PM, Kevin Jacobs wrote: > A FLANN implementation should be even faster--perhaps by as much as another > factor of two. I guess it depends on whether you care about the "Approximate" in "Fast Library for Approximate Nearest Neighbors". Stéfan _

Re: [Numpy-discussion] record arrays initialization

2012-05-02 Thread Stéfan van der Walt
On Wed, May 2, 2012 at 4:26 PM, Moroney, Catherine M (388D) wrote: > Using structured arrays is making my code complex when I try to call the > vectorized function.  If I stick to the original record arrays, what's the > best way of initializing b from a without doing an row-by-row copy? What doe

Re: [Numpy-discussion] record arrays initialization

2012-05-02 Thread Kevin Jacobs
On Wed, May 2, 2012 at 7:25 PM, Aronne Merrelli wrote: > In general this is a good suggestion - I was going to mention it > earlier - but I think for this particular problem it is not better > than the "brute force" and argmin() NumPy approach. On my laptop, the > KDTree query is about a factor of

[Numpy-discussion] record arrays initialization

2012-05-02 Thread Moroney, Catherine M (388D)
On May 2, 2012, at 3:23 PM, wrote: >> A) ?How do I most efficiently construct a record array from a single array? >> I want to do the following, but it segfaults on me when i try to print b. >> >> vtype = [("x", numpy.ndarray)] >> a = numpy.arange(0, 16).reshape(4,4) >> b = numpy.recarray((4)

Re: [Numpy-discussion] record arrays initialization

2012-05-02 Thread Aronne Merrelli
On Wed, May 2, 2012 at 5:27 PM, Kevin Jacobs wrote: > On Wed, May 2, 2012 at 5:45 PM, Moroney, Catherine M (388D) > wrote: >> >> Thanks to Perry for some very useful off-list conversation.   I realize >> that >> I wasn't being clear at all in my earlier description of the problem so >> here it i

Re: [Numpy-discussion] record arrays initialization

2012-05-02 Thread Kevin Jacobs
On Wed, May 2, 2012 at 5:45 PM, Moroney, Catherine M (388D) < catherine.m.moro...@jpl.nasa.gov> wrote: > Thanks to Perry for some very useful off-list conversation. I realize > that > I wasn't being clear at all in my earlier description of the problem so > here it is > in a nutshell: > > Find t

Re: [Numpy-discussion] record arrays initialization

2012-05-02 Thread Stéfan van der Walt
On Wed, May 2, 2012 at 2:45 PM, Moroney, Catherine M (388D) wrote: > Find the best match in an array t(5000, 7) for a single vector e(7).  Now > scale > it up so e is (128, 512, 7) and I want to return a (128, 512) array of the > t-identifiers > that are the best match for e.  "Best match" is de

[Numpy-discussion] record arrays initialization

2012-05-02 Thread Moroney, Catherine M (388D)
Thanks to Perry for some very useful off-list conversation. I realize that I wasn't being clear at all in my earlier description of the problem so here it is in a nutshell: Find the best match in an array t(5000, 7) for a single vector e(7). Now scale it up so e is (128, 512, 7) and I want to