Re: [Numpy-discussion] ANN: line_profiler 1.0b2 released

2009-07-20 Thread Nicolas Pinto
Thanks a lot Robert for this very useful tool! I was wondering if there is a way to make it work with Cython code (see below) ? Sincerely, Nicolas fib.pyx: @profile def fib(n): Print the Fibonacci series up to n. a, b = 0, 1 while b n: a, b = b, a + b test.py: import

[Numpy-discussion] Repeated Dot Operations

2009-07-20 Thread T J
Hi, Is there a good way to perform dot on an arbitrary list of arrays which avoids using a loop? Here is what I'd like to avoid: # m1, m2, m3  are arrays out = np.(m1.shape[0]) prod = [m1, m2, m3, m1, m2, m3, m3, m2] for m in prod: ... out = np.dot(out, m) ... I was hoping for something

Re: [Numpy-discussion] String manipulation

2009-07-20 Thread Nils Wagner
On Mon, 11 May 2009 10:48:14 -0400 Alan G Isaac ais...@american.edu wrote: On 5/11/2009 8:36 AM Nils Wagner apparently wrote: I would like to split strings made of digits after eight characters each. [l[i*8:(i+1)*8] for i in range(len(l)/8)] Alan Isaac

[Numpy-discussion] re carray and datetime objects

2009-07-20 Thread John [H2O]
Hello, I have a file containing mixed data types: strings, floats, datetime output(i.e. strings), and ints. Something like: #ID, name, date, value 1,sample,2008-07-10 12:34:20,344.56 And so forth. It seems using recarrays is efficient and a prefered habit to get into wrg to numpy, so I am

[Numpy-discussion] indexing recarrays

2009-07-20 Thread John [H2O]
I have a file containing mixed data types: strings, floats, datetime output(i.e. strings), and ints. Something like: #ID, name, date, value 1,sample,2008-07-10 12:34:20,344.56 Presuming I get them nicely into a recarray (see my other

Re: [Numpy-discussion] My identity

2009-07-20 Thread Charles R Harris
On Mon, Jul 20, 2009 at 9:39 AM, Keith Goodman kwgood...@gmail.com wrote: Using a trick that Robert Kern recently posted to the list makes the identity function much faster. Current version: def identity(n, dtype=None): a = array([1]+n*[0],dtype=dtype) b = empty((n,n),dtype=dtype)

Re: [Numpy-discussion] indexing recarrays

2009-07-20 Thread Pierre GM
On Jul 20, 2009, at 7:54 AM, John [H2O] wrote: I have a file containing mixed data types: strings, floats, datetime output(i.e. strings), and ints. Something like: #ID, name, date, value 1,sample,2008-07-10 12:34:20,344.56 Presuming I get them nicely into a recarray (see my other post)

Re: [Numpy-discussion] ANN: line_profiler 1.0b2 released

2009-07-20 Thread Robert Kern
On Mon, Jul 20, 2009 at 01:42, Nicolas Pintopi...@mit.edu wrote: Thanks a lot Robert for this very useful tool! I was wondering if there is a way to make it work with Cython code (see below) ? No, line_profiler cannot work with Cython. There is some talk on the Cython mailing list about

Re: [Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
On Mon, Jul 20, 2009 at 9:03 AM, Charles R Harrischarlesr.har...@gmail.com wrote: On Mon, Jul 20, 2009 at 9:39 AM, Keith Goodman kwgood...@gmail.com wrote: Using a trick that Robert Kern recently posted to the list makes the identity function much faster. Current version: def identity(n,

Re: [Numpy-discussion] Repeated Dot Operations

2009-07-20 Thread Robert Kern
On Mon, Jul 20, 2009 at 05:27, T Jtjhn...@gmail.com wrote: Hi, Is there a good way to perform dot on an arbitrary list of arrays which avoids using a loop?  Here is what I'd like to avoid: # m1, m2, m3  are arrays out = np.(m1.shape[0]) prod = [m1, m2, m3, m1, m2, m3, m3, m2] for m in

Re: [Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
On Mon, Jul 20, 2009 at 9:32 AM, Keith Goodmankwgood...@gmail.com wrote: On Mon, Jul 20, 2009 at 9:03 AM, Charles R Harrischarlesr.har...@gmail.com wrote: On Mon, Jul 20, 2009 at 9:39 AM, Keith Goodman kwgood...@gmail.com wrote: Using a trick that Robert Kern recently posted to the list

Re: [Numpy-discussion] My identity

2009-07-20 Thread Pauli Virtanen
On 2009-07-20, Keith Goodman kwgood...@gmail.com wrote: [clip] Oh, sorry, I misunderstood. Yes, a similar change was made to eye but not to identity. Nasty, duplicated code there it seems... -- Pauli Virtanen ___ NumPy-Discussion mailing list

Re: [Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
On Mon, Jul 20, 2009 at 10:53 AM, Pauli Virtanenpav...@iki.fi wrote: On 2009-07-20, Keith Goodman kwgood...@gmail.com wrote: [clip] Oh, sorry, I misunderstood. Yes, a similar change was made to eye but not to identity. Nasty, duplicated code there it seems... So def myidentity2(n,

[Numpy-discussion] Update numpy.lib.ufunclike.log2

2009-07-20 Thread Brian Lewis
Should numpy.lib.ufunclike.log2 be updated to: x = nx.asanyarray(x) if y is None: y = nx.log2(x) else: nx.log2(x, y) return y ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org

Re: [Numpy-discussion] Update numpy.lib.ufunclike.log2

2009-07-20 Thread Brian Lewis
On Mon, Jul 20, 2009 at 12:12 PM, Brian Lewis brian.lewi...@gmail.comwrote: Should numpy.lib.ufunclike.log2 be updated to: x = nx.asanyarray(x) if y is None: y = nx.log2(x) else: nx.log2(x, y) return y Or perhaps removed since numpy.core.umath.log2

Re: [Numpy-discussion] find_common_type broken?

2009-07-20 Thread Travis Oliphant
On Jul 16, 2009, at 12:59 AM, Ralf Gommers wrote: This is not a problem with r_. This is correct behavior. A scalar float will not cause an array float32 to be upcast. This was at first counter-intuitive but I found the reason for it in Guide to Numpy now: Mixed scalar-array

Re: [Numpy-discussion] My identity

2009-07-20 Thread David Goldsmith
Just to be clear, in which namespace(s) are we talking about making (or having made) the change: IIUC, the result you're talking about would be inappropriate for ufunc.identity. DG --- On Mon, 7/20/09, Keith Goodman kwgood...@gmail.com wrote: From: Keith Goodman kwgood...@gmail.com

Re: [Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
On Mon, Jul 20, 2009 at 1:11 PM, David Goldsmithd_l_goldsm...@yahoo.com wrote: Just to be clear, in which namespace(s) are we talking about making (or having made) the change: IIUC, the result you're talking about would be inappropriate for ufunc.identity. np.identity np.matlib.identity

Re: [Numpy-discussion] My identity

2009-07-20 Thread Citi, Luca
Just my 2 cents. It is duplicated code. But it is only 3 lines. identity does not need to handle rectangular matrices and non-principal diagonals, therefore it can be reasonably faster (especially for small matrices, I guess). ___ NumPy-Discussion

Re: [Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
On Mon, Jul 20, 2009 at 1:44 PM, Citi, Lucalc...@essex.ac.uk wrote: Just my 2 cents. It is duplicated code. But it is only 3 lines. identity does not need to handle rectangular matrices and non-principal diagonals, therefore it can be reasonably faster (especially for small matrices, I

Re: [Numpy-discussion] suggestion for generalizing numpy functions

2009-07-20 Thread Stéfan van der Walt
Hi Chuck 2009/7/17 Charles R Harris charlesr.har...@gmail.com: PyObject* PyTuple_GetItem(PyObject *p, Py_ssize_t pos) Return value: Borrowed reference. Return the object at position pos in the tuple pointed to by p. If pos is out of bounds, return NULL and sets an IndexError exception. It's a