Re: [Numpy-discussion] record arrays with char*?

2014-02-11 Thread Chris Barker
On Tue, Feb 11, 2014 at 8:57 AM, Christopher Jordan-Squire wrote: > Thanks for the answers! My responses are inline. my C is a bit weak, so forgive my misunderstanding, but: >> { >> char* ind; >> double val, wght; >> } data[] = { {"camera", 15, 2}, {"necklace", 100, 20}, {"vase", 90, 20}, >>

Re: [Numpy-discussion] record arrays with char*?

2014-02-11 Thread Christopher Jordan-Squire
Thanks for the answers! My responses are inline. On Tue, Feb 11, 2014 at 8:36 AM, Chris Barker wrote: > On Mon, Feb 10, 2014 at 10:43 PM, Christopher Jordan-Squire > wrote: >> >> I'm trying to wrap some C code using cython. The C code can take >> inputs in two modes: dense inputs and sparse inpu

Re: [Numpy-discussion] record arrays with char*?

2014-02-11 Thread Chris Barker
On Mon, Feb 10, 2014 at 10:43 PM, Christopher Jordan-Squire wrote: > I'm trying to wrap some C code using cython. The C code can take > inputs in two modes: dense inputs and sparse inputs. For dense inputs > the array indexing is naive. I have wrappers for that. In the sparse > case the matrix en

[Numpy-discussion] record arrays with char*?

2014-02-10 Thread Christopher Jordan-Squire
I'm trying to wrap some C code using cython. The C code can take inputs in two modes: dense inputs and sparse inputs. For dense inputs the array indexing is naive. I have wrappers for that. In the sparse case the matrix entries are typically indexed via names. So, for example, the library documenta

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 and vectorizing

2012-05-03 Thread Richard Hattersley
Sounds like it could be a good match for `scipy.spatial.cKDTree`. It can handle single-element queries... >>> element = numpy.arange(1, 8) >>> targets = numpy.random.uniform(0, 8, (1000, 7)) >>> tree = scipy.spatial.cKDTree(targets) >>> distance, index = tree.query(element) >>> targets[index] arr

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

Re: [Numpy-discussion] record arrays and vectorizing

2012-05-02 Thread Aronne Merrelli
On Wed, May 2, 2012 at 1:06 PM, Moroney, Catherine M (388D) wrote: > Hello, > > Can somebody give me some hints as to how to code up this function > in pure python, rather than dropping down to Fortran? > > I will want to compare a 7-element vector (called "element") to a large list > of similarl

[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

Re: [Numpy-discussion] record arrays and vectorizing

2012-05-02 Thread Stéfan van der Walt
On Wed, May 2, 2012 at 11:06 AM, Moroney, Catherine M (388D) wrote: > I will want to compare a 7-element vector (called "element") to a large list > of similarly-dimensioned > vectors (called "target", and pick out the vector in "target" that is the > closest to "element" > (determined by minimi

[Numpy-discussion] record arrays and vectorizing

2012-05-02 Thread Moroney, Catherine M (388D)
Hello, Can somebody give me some hints as to how to code up this function in pure python, rather than dropping down to Fortran? I will want to compare a 7-element vector (called "element") to a large list of similarly-dimensioned vectors (called "target", and pick out the vector in "target" that

Re: [Numpy-discussion] Record arrays, nesting, and assignment

2009-07-15 Thread Robert Kern
On Wed, Jul 15, 2009 at 14:38, Pauli Virtanen wrote: > On 2009-07-15, Robert Kern wrote: >> On Wed, Jul 15, 2009 at 14:19, Vebjorn Ljosa wrote: >>> Suppose I have a record array where one of the fields is a nested array: >>> >>>  >>> from numpy import * >>>  >>> desc = dtype([('point', 'i4', 3), (

Re: [Numpy-discussion] Record arrays, nesting, and assignment

2009-07-15 Thread Pauli Virtanen
On 2009-07-15, Robert Kern wrote: > On Wed, Jul 15, 2009 at 14:19, Vebjorn Ljosa wrote: >> Suppose I have a record array where one of the fields is a nested array: >> >>  >>> from numpy import * >>  >>> desc = dtype([('point', 'i4', 3), ('unimportant', 'S3')]) >>  >>> a = array([((1,2,3), 'foo'),

Re: [Numpy-discussion] Record arrays, nesting, and assignment

2009-07-15 Thread Vebjorn Ljosa
On Jul 15, 2009, at 15:28, Robert Kern wrote: > > Generally, scalars are never views. a[0] pulls out a record scalar. Thank you, that explains it. I should have noticed that a[0] was just a tuple. Vebjorn ___ NumPy-Discussion mailing list NumPy-Discu

Re: [Numpy-discussion] Record arrays, nesting, and assignment

2009-07-15 Thread Robert Kern
On Wed, Jul 15, 2009 at 14:19, Vebjorn Ljosa wrote: > Suppose I have a record array where one of the fields is a nested array: > >  >>> from numpy import * >  >>> desc = dtype([('point', 'i4', 3), ('unimportant', 'S3')]) >  >>> a = array([((1,2,3), 'foo'), ((7,8,9), 'bar')], dtype=desc) >  >>> a >

[Numpy-discussion] Record arrays, nesting, and assignment

2009-07-15 Thread Vebjorn Ljosa
Suppose I have a record array where one of the fields is a nested array: >>> from numpy import * >>> desc = dtype([('point', 'i4', 3), ('unimportant', 'S3')]) >>> a = array([((1,2,3), 'foo'), ((7,8,9), 'bar')], dtype=desc) >>> a array([([1, 2, 3], 'foo'), ([7, 8, 9], 'bar')], dtype=[('po

Re: [Numpy-discussion] Record arrays

2008-07-03 Thread Stéfan van der Walt
2008/6/27 Fernando Perez <[EMAIL PROTECTED]>: > On Thu, Jun 26, 2008 at 1:25 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > >> One downside of this is that the attribute access feature slows down >> all field accesses, even the r['foo'] form, because it sticks a bunch >> of pure Python code in the mi

Re: [Numpy-discussion] Record arrays

2008-06-29 Thread Christopher Hanley
Perry Greenfield wrote: > Hi Chris, > > Didn't we remove all dependence on recarray? I could have sworn we > did that. > > Perry > Perry, You are right. We no longer import the recarray module from numpy. Chris -- Christopher Hanley Systems Software Engineer Space Telescope Science Ins

Re: [Numpy-discussion] Record arrays

2008-06-29 Thread Perry Greenfield
Hi Chris, Didn't we remove all dependence on recarray? I could have sworn we did that. Perry On Jun 26, 2008, at 12:45 PM, Christopher Hanley wrote: > Travis E. Oliphant wrote: >> Stéfan van der Walt wrote: >>> Hi all, >>> >>> I am documenting `recarray`, and have a question: >>> >>> Is its u

Re: [Numpy-discussion] Record arrays

2008-06-27 Thread Sebastian Haase
On Fri, Jun 27, 2008 at 7:10 AM, Fernando Perez <[EMAIL PROTECTED]> wrote: > On Thu, Jun 26, 2008 at 1:25 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > >> One downside of this is that the attribute access feature slows down >> all field accesses, even the r['foo'] form, because it sticks a bunch >>

Re: [Numpy-discussion] Record arrays

2008-06-26 Thread Fernando Perez
On Thu, Jun 26, 2008 at 1:25 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > One downside of this is that the attribute access feature slows down > all field accesses, even the r['foo'] form, because it sticks a bunch > of pure Python code in the middle. Much code won't notice this, but if > you end

Re: [Numpy-discussion] Record arrays

2008-06-26 Thread Gael Varoquaux
On Thu, Jun 26, 2008 at 09:36:38PM -0500, Robert Kern wrote: > On Thu, Jun 26, 2008 at 21:24, Gael Varoquaux > <[EMAIL PROTECTED]> wrote: > > I understand all your comments and thank you for making this distinction > > explicit. I can see why recarray can slow code down, but I find attribute > > lo

Re: [Numpy-discussion] Record arrays

2008-06-26 Thread Robert Kern
On Thu, Jun 26, 2008 at 21:24, Gael Varoquaux <[EMAIL PROTECTED]> wrote: > I understand all your comments and thank you for making this distinction > explicit. I can see why recarray can slow code down, but I find attribute > lookup make code much more readable, and interactive work fantastic (tab

Re: [Numpy-discussion] Record arrays

2008-06-26 Thread Gael Varoquaux
I understand all your comments and thank you for making this distinction explicit. I can see why recarray can slow code down, but I find attribute lookup make code much more readable, and interactive work fantastic (tab completion). For many of my applications I do have a strong use case for these

Re: [Numpy-discussion] Record arrays

2008-06-26 Thread Travis E. Oliphant
> Does that clarify the discussion for you? > > > > > Yes, thanks very much, this is very helpful. (I think I was confused > by the fact that, AFAICT, the Guide to Numpy only mentions recarray -- > as distinct from Record arrays -- in one somewhat cryptic line.) But > I guess that the nu

Re: [Numpy-discussion] Record arrays

2008-06-26 Thread Dan Yamins
> > In [12]: r2.foo > Out[12]: array([1, 1, 1]) > > > One downside of this is that the attribute access feature slows down > all field accesses, even the r['foo'] form, because it sticks a bunch > of pure Python code in the middle. Much code won't notice this, but if > you end up having to iterate

Re: [Numpy-discussion] Record arrays

2008-06-26 Thread Gabriel Gellner
> Let's be clear, there are two very closely related things: recarrays > and record arrays. Record arrays are just ndarrays with a complicated > dtype. E.g. > > In [1]: from numpy import * > > In [2]: ones(3, dtype=dtype([('foo', int), ('bar', float)])) > Out[2]: > array([(1, 1.0), (1, 1.0), (1,

Re: [Numpy-discussion] Record arrays

2008-06-26 Thread Robert Kern
On Thu, Jun 26, 2008 at 15:13, Dan Yamins <[EMAIL PROTECTED]> wrote: > > On Thu, Jun 26, 2008 at 3:34 PM, Gael Varoquaux > <[EMAIL PROTECTED]> wrote: >> >> On Thu, Jun 26, 2008 at 11:48:06AM -0500, John Hunter wrote: >> > I personally think they are the best thing since sliced bread, and >> > every

Re: [Numpy-discussion] Record arrays

2008-06-26 Thread Dan Yamins
On Thu, Jun 26, 2008 at 3:34 PM, Gael Varoquaux < [EMAIL PROTECTED]> wrote: > On Thu, Jun 26, 2008 at 11:48:06AM -0500, John Hunter wrote: > > I personally think they are the best thing since sliced bread, and > > everyone here who uses them becomes immediately addicted to them. I > > would like

Re: [Numpy-discussion] Record arrays

2008-06-26 Thread Gael Varoquaux
On Thu, Jun 26, 2008 at 11:48:06AM -0500, John Hunter wrote: > I personally think they are the best thing since sliced bread, and > everyone here who uses them becomes immediately addicted to them. I > would like to see better support for them, especially making the attrs > exposed to dir so tab c

[Numpy-discussion] Record arrays

2008-06-26 Thread Vince Fulco
Would someone kindly provide links to references for the fancy data types superseding the recarrays? Having come from an R-Project background, manipulating the latter takes time to become acclimated to when building data.frame like objects. TIA, -- Vince Fulco __

Re: [Numpy-discussion] Record arrays

2008-06-26 Thread John Hunter
On Thu, Jun 26, 2008 at 11:38 AM, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > Stéfan van der Walt wrote: >> Hi all, >> >> I am documenting `recarray`, and have a question: >> >> Is its use still recommended, or has it been superseded by fancy data-types? >> > I rarely recommend it's use (but so

Re: [Numpy-discussion] Record arrays

2008-06-26 Thread Christopher Hanley
Travis E. Oliphant wrote: > Stéfan van der Walt wrote: >> Hi all, >> >> I am documenting `recarray`, and have a question: >> >> Is its use still recommended, or has it been superseded by fancy data-types? >> > I rarely recommend it's use (but some people do like attribute access to > the fields

Re: [Numpy-discussion] Record arrays

2008-06-26 Thread Travis E. Oliphant
Stéfan van der Walt wrote: > Hi all, > > I am documenting `recarray`, and have a question: > > Is its use still recommended, or has it been superseded by fancy data-types? > I rarely recommend it's use (but some people do like attribute access to the fields).It is wrong, however, to say tha

Re: [Numpy-discussion] Record arrays

2008-06-26 Thread Christopher Hanley
Stéfan van der Walt wrote: > Hi all, > > I am documenting `recarray`, and have a question: > > Is its use still recommended, or has it been superseded by fancy data-types? > > Regards > Stéfan > ___ > Numpy-discussion mailing list > Numpy-discussion@sc

[Numpy-discussion] Record arrays

2008-06-26 Thread Stéfan van der Walt
Hi all, I am documenting `recarray`, and have a question: Is its use still recommended, or has it been superseded by fancy data-types? Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinf

Re: [Numpy-discussion] Record Arrays and ctypes Interfacing

2008-03-18 Thread vel . accel
On Tue, Mar 18, 2008 at 2:18 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > > On Tue, Mar 18, 2008 at 9:48 AM, <[EMAIL PROTECTED]> wrote: > > Hi all, > > > > How do I handle numpy record arrays (heterogenous dtype) with ctypes? > > The python side is reasonably obvious to me, but I'm confused

Re: [Numpy-discussion] Record Arrays and ctypes Interfacing

2008-03-18 Thread Robert Kern
On Tue, Mar 18, 2008 at 9:48 AM, <[EMAIL PROTECTED]> wrote: > Hi all, > > How do I handle numpy record arrays (heterogenous dtype) with ctypes? > The python side is reasonably obvious to me, but I'm confused about > how to declare my C function's signature; whether I need to include > the nump

[Numpy-discussion] Record Arrays and ctypes Interfacing

2008-03-18 Thread vel . accel
Hi all, How do I handle numpy record arrays (heterogenous dtype) with ctypes? The python side is reasonably obvious to me, but I'm confused about how to declare my C function's signature; whether I need to include the numpy array interface header file or not... etc... It's not obvious to me how a