Re: [Numpy-discussion] Optimization suggestion sought

2010-12-29 Thread Robert Bradshaw
On Mon, Dec 27, 2010 at 6:20 AM, Enzo Michelangeli enzom...@gmail.com wrote: Many thanks to Josef and Justin for their replies. Josef's hint sounds like a good way of reducing peak memory allocation especially when the row size is large, which makes the for overhead for each iteration

Re: [Numpy-discussion] fromrecords yields ValueError: invalid itemsize in generic type tuple

2010-12-29 Thread Friedrich Romstedt
2010/12/7 Rajat Banerjee rban...@fas.harvard.edu: Hi All, I have been using Numpy for a while with great success. I left my little project for a little while (http://web.mit.edu/stardev/cluster/) and now some of my code is broken. I have some Numpy code to create graphs of activity on a

Re: [Numpy-discussion] NumPy C-API equivalent of np.float64()

2010-12-29 Thread Keith Goodman
On Tue, Dec 28, 2010 at 11:22 PM, Robert Bradshaw rober...@math.washington.edu wrote: On Tue, Dec 28, 2010 at 8:10 PM, John Salvatier jsalv...@u.washington.edu wrote: Wouldn't that be a cast? You do casts in Cython with double(expression) and that should be the equivalent of float64 I think.

Re: [Numpy-discussion] NumPy C-API equivalent of np.float64()

2010-12-29 Thread Robert Bradshaw
On Wed, Dec 29, 2010 at 9:05 AM, Keith Goodman kwgood...@gmail.com wrote: On Tue, Dec 28, 2010 at 11:22 PM, Robert Bradshaw rober...@math.washington.edu wrote: On Tue, Dec 28, 2010 at 8:10 PM, John Salvatier jsalv...@u.washington.edu wrote: Wouldn't that be a cast? You do casts in Cython with

Re: [Numpy-discussion] NumPy C-API equivalent of np.float64()

2010-12-29 Thread Keith Goodman
On Wed, Dec 29, 2010 at 9:37 AM, Robert Bradshaw rober...@math.washington.edu wrote: On Wed, Dec 29, 2010 at 9:05 AM, Keith Goodman kwgood...@gmail.com wrote: On Tue, Dec 28, 2010 at 11:22 PM, Robert Bradshaw rober...@math.washington.edu wrote: On Tue, Dec 28, 2010 at 8:10 PM, John Salvatier

Re: [Numpy-discussion] NumPy C-API equivalent of np.float64()

2010-12-29 Thread Matthew Brett
Hi, On Wed, Dec 29, 2010 at 5:37 PM, Robert Bradshaw rober...@math.washington.edu wrote: On Wed, Dec 29, 2010 at 9:05 AM, Keith Goodman kwgood...@gmail.com wrote: On Tue, Dec 28, 2010 at 11:22 PM, Robert Bradshaw rober...@math.washington.edu wrote: On Tue, Dec 28, 2010 at 8:10 PM, John

Re: [Numpy-discussion] NumPy C-API equivalent of np.float64()

2010-12-29 Thread Keith Goodman
On Wed, Dec 29, 2010 at 9:48 AM, Matthew Brett matthew.br...@gmail.com wrote: Hi, On Wed, Dec 29, 2010 at 5:37 PM, Robert Bradshaw rober...@math.washington.edu wrote: On Wed, Dec 29, 2010 at 9:05 AM, Keith Goodman kwgood...@gmail.com wrote: On Tue, Dec 28, 2010 at 11:22 PM, Robert Bradshaw

Re: [Numpy-discussion] NumPy C-API equivalent of np.float64()

2010-12-29 Thread Matthew Brett
Forgive me if I haven't understood your question, but can you use PyArray_DescrFromType with e.g  NPY_FLOAT64 ? I'm pretty hopeless here. I don't know how to put all that together in a function. That might be because I'm not understanding you very well, but I was thinking that: cdef dtype

Re: [Numpy-discussion] NumPy C-API equivalent of np.float64()

2010-12-29 Thread Keith Goodman
On Wed, Dec 29, 2010 at 10:13 AM, Matthew Brett matthew.br...@gmail.com wrote: Forgive me if I haven't understood your question, but can you use PyArray_DescrFromType with e.g  NPY_FLOAT64 ? I'm pretty hopeless here. I don't know how to put all that together in a function. That might be

Re: [Numpy-discussion] NumPy C-API equivalent of np.float64()

2010-12-29 Thread Matthew Brett
Hi, That might be because I'm not understanding you very well, but I was thinking that: cdef dtype descr = PyArray_DescrFromType(NPY_FLOAT64) would give you the float64 dtype that I thought you wanted?  I'm shooting from the hip here, in between nieces competing for the computer and my

Re: [Numpy-discussion] NumPy C-API equivalent of np.float64()

2010-12-29 Thread Keith Goodman
On Wed, Dec 29, 2010 at 11:43 AM, Matthew Brett matthew.br...@gmail.com wrote: Hi, That might be because I'm not understanding you very well, but I was thinking that: cdef dtype descr = PyArray_DescrFromType(NPY_FLOAT64) would give you the float64 dtype that I thought you wanted?  I'm

Re: [Numpy-discussion] NumPy C-API equivalent of np.float64()

2010-12-29 Thread Pauli Virtanen
Keith Goodman wrote: np.float64 is fast, just hoping someone had a C-API inline version of np.float64() that is faster. You're looking for PyArrayScalar_New and _ASSIGN. See https://github.com/numpy/numpy/blob/master/numpy/core/include/numpy/arrayscalars.h Undocumented (bad), but AFAIK

Re: [Numpy-discussion] NumPy C-API equivalent of np.float64()

2010-12-29 Thread Keith Goodman
On Wed, Dec 29, 2010 at 11:54 AM, Pauli Virtanen p...@iki.fi wrote: Keith Goodman wrote: np.float64 is fast, just hoping someone had a C-API inline version of np.float64() that is faster. You're looking for PyArrayScalar_New and _ASSIGN. See