Re: [Numpy-discussion] String manipulation

2009-07-20 Thread Pierre GM
On Jul 20, 2009, at 3:44 PM, Christopher Barker wrote: > ... > Is there a cleaner way to do this? > > -Chris Yes. np.lib._iotools.LineSplitter and/or np.genfromtxt ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailma

Re: [Numpy-discussion] String manipulation

2009-07-20 Thread Pierre GM
On Jul 21, 2009, at 2:42 AM, Nils Wagner wrote: > > Fixed-length fields are quite common e.g. in the area of > Finite Element pre/postprocessing. > Therefore It would be nice to have a function like > line2array in numpy. > Comments ? Er, there's already something like that: np.lib._iotools.LineS

Re: [Numpy-discussion] String manipulation

2009-07-20 Thread Nils Wagner
On Mon, 20 Jul 2009 12:44:23 -0700 Christopher Barker wrote: > Nils Wagner wrote: >> How can I split the second line in such a way that I get >> >> ['-1.00E+00', '-1.00E+00', '-1.00E+00', >> '-1.00E+00', '1.25E+00', '1.25E+00'] >> >> instead of >> >> ['-1.00E+00-1

Re: [Numpy-discussion] numpy/core/code_generators/../src/multiarray/iterators.c:1778:could not find function name

2009-07-20 Thread Nils Wagner
On Tue, 21 Jul 2009 15:05:02 +0900 David Cournapeau wrote: > Nils Wagner wrote: >> Hi all, >> >> I cannot build numpy from svn. >> > > Yes, I don't know why I did not caught this error on my >machine. In any > case, it is fixed in r7175. > > cheers, > > David Great. Works for me. Nil

Re: [Numpy-discussion] numpy/core/code_generators/../src/multiarray/iterators.c:1778:could not find function name

2009-07-20 Thread David Cournapeau
Nils Wagner wrote: > Hi all, > > I cannot build numpy from svn. > Yes, I don't know why I did not caught this error on my machine. In any case, it is fixed in r7175. cheers, David ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://m

[Numpy-discussion] numpy/core/code_generators/../src/multiarray/iterators.c:1778:could not find function name

2009-07-20 Thread Nils Wagner
Hi all, I cannot build numpy from svn. ... adding 'build/src.linux-x86_64-2.5/numpy/core/include/numpy/numpyconfig.h' to sources. executing numpy/core/code_generators/generate_numpy_api.py numpy/core/code_generators/../src/multiarray/iterators.c 1778 Traceback (most recent call last): Fi

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 : > 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 borrowed > reference

Re: [Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
On Mon, Jul 20, 2009 at 1:44 PM, Citi, Luca 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 > guess). I

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 mai

Re: [Numpy-discussion] My identity

2009-07-20 Thread David Goldsmith
OK, thanks! (Forgive my being a stickler, but I think it's good to have it in the thread, for posterity.) DG --- On Mon, 7/20/09, Keith Goodman wrote: > From: Keith Goodman > Subject: Re: [Numpy-discussion] My identity > To: "Discussion of Numerical Python" > Date: Monday, July 20, 2009, 1

Re: [Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
On Mon, Jul 20, 2009 at 1:11 PM, David Goldsmith 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 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 wrote: > From: Keith Goodman > Subject: Re: [Numpy-discussion] My identity

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 scal

Re: [Numpy-discussion] String manipulation

2009-07-20 Thread Christopher Barker
Nils Wagner wrote: How can I split the second line in such a way that I get ['-1.00E+00', '-1.00E+00', '-1.00E+00', '-1.00E+00', '1.25E+00', '1.25E+00'] instead of ['-1.00E+00-1.00E+00-1.00E+00-1.00E+00', '1.25E+00', '1.25E+00'] It looks lik

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 wrote: > 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 exists... __

[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 http://mail.scipy.org/mailman/listi

Re: [Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
On Mon, Jul 20, 2009 at 10:53 AM, Pauli Virtanen wrote: > On 2009-07-20, Keith Goodman 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, dtype=None): return eye(n, M=

Re: [Numpy-discussion] My identity

2009-07-20 Thread Pauli Virtanen
On 2009-07-20, Keith Goodman 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 NumPy-Discussion@scipy.

Re: [Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
On Mon, Jul 20, 2009 at 9:32 AM, Keith Goodman wrote: > On Mon, Jul 20, 2009 at 9:03 AM, Charles R > Harris wrote: >> >> >> On Mon, Jul 20, 2009 at 9:39 AM, Keith Goodman wrote: >>> >>> Using a trick that Robert Kern recently posted to the list makes the >>> identity function much faster. >>> >>>

Re: [Numpy-discussion] Repeated Dot Operations

2009-07-20 Thread Robert Kern
On Mon, Jul 20, 2009 at 05:27, T J 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 pro

Re: [Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
On Mon, Jul 20, 2009 at 9:03 AM, Charles R Harris wrote: > > > On Mon, Jul 20, 2009 at 9:39 AM, Keith Goodman 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 = arra

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

2009-07-20 Thread Robert Kern
On Mon, Jul 20, 2009 at 01:42, Nicolas Pinto 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 implementing fu

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] My identity

2009-07-20 Thread Charles R Harris
On Mon, Jul 20, 2009 at 9:39 AM, Keith Goodman 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) >b.flat =

[Numpy-discussion] My identity

2009-07-20 Thread Keith Goodman
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) b.flat = a return b Proposed version: def myidentity(n, dtype=None):

[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 http://www.nabble.com/recarray-and-datetime-objects-td245683

[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 tryin

Re: [Numpy-discussion] String manipulation

2009-07-20 Thread Nils Wagner
On Mon, 11 May 2009 10:48:14 -0400 Alan G Isaac 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] 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 somet