Re: [Numpy-discussion] numarray iterator question

2010-03-10 Thread Warren Weckesser
Neal Becker wrote: > This is a bit confusing to me: > > import numpy as np > > u = np.ones ((3,3)) > > for u_row in u: > u_row = u_row * 2 << doesn't work > > Try this instead: for u_row in u: u_row[:] = u_row * 2 Warren > print u > [[ 1. 1. 1.] > [ 1. 1. 1.] > [ 1. 1. 1.]]

Re: [Numpy-discussion] numarray iterator question

2010-03-10 Thread Robert Kern
On Wed, Mar 10, 2010 at 18:19, Neal Becker wrote: > This is a bit confusing to me: > > import numpy as np > > u = np.ones ((3,3)) > > for u_row in u: >    u_row = u_row * 2  << doesn't work > > print u > [[ 1.  1.  1.] >  [ 1.  1.  1.] >  [ 1.  1.  1.]] > > for u_row in u: >    u_row *= 2  << does

[Numpy-discussion] numarray iterator question

2010-03-10 Thread Neal Becker
This is a bit confusing to me: import numpy as np u = np.ones ((3,3)) for u_row in u: u_row = u_row * 2 << doesn't work print u [[ 1. 1. 1.] [ 1. 1. 1.] [ 1. 1. 1.]] for u_row in u: u_row *= 2 << does work [[ 2. 2. 2.] [ 2. 2. 2.] [ 2. 2. 2.]] Naively, I'm thinking a

Re: [Numpy-discussion] crash at prompt exit after running test

2010-03-10 Thread Charles R Harris
On Wed, Mar 10, 2010 at 10:39 AM, Bruce Southey wrote: > On 03/10/2010 08:59 AM, Pauli Virtanen wrote: > > Wed, 10 Mar 2010 15:40:04 +0100, Johann Cohen-Tanugi wrote: > > > >> Pauli, isn't it hopeless to follow the execution of the source code when > >> the crash actually occurs when I exit, and

Re: [Numpy-discussion] Backwards slicing including the first element

2010-03-10 Thread Chris Barker
> Jerome Esteve wrote: >> Is there a way to give an integer value to j when using a[i:j:-1] so >> that the first element of the array can be included in the slice ? Is this what you are looking for? In [11]: a = np.arange(10) In [12]: a[6::-1] Out[12]: array([6, 5, 4, 3, 2, 1, 0]) I know it's

Re: [Numpy-discussion] crash at prompt exit after running test

2010-03-10 Thread Bruce Southey
On 03/10/2010 08:59 AM, Pauli Virtanen wrote: > Wed, 10 Mar 2010 15:40:04 +0100, Johann Cohen-Tanugi wrote: > >> Pauli, isn't it hopeless to follow the execution of the source code when >> the crash actually occurs when I exit, and not when I execute. I would >> have to understand enough of thi

Re: [Numpy-discussion] Backwards slicing including the first element

2010-03-10 Thread josef . pktd
On Wed, Mar 10, 2010 at 10:19 AM, Warren Weckesser wrote: > Warren Weckesser wrote: >> Jerome Esteve wrote: >> >>> Dear all, >>> >>> Is there a way to give an integer value to j when using a[i:j:-1] so >>> that the first element of the array can be included in the slice ? >>> >>> I would like to u

Re: [Numpy-discussion] Backwards slicing including the first element

2010-03-10 Thread Warren Weckesser
Warren Weckesser wrote: > Jerome Esteve wrote: > >> Dear all, >> >> Is there a way to give an integer value to j when using a[i:j:-1] so >> that the first element of the array can be included in the slice ? >> >> I would like to use some code like a[i:i-k:-1] to get a slice of >> length k. >>

Re: [Numpy-discussion] crash at prompt exit after running test

2010-03-10 Thread Bruce Southey
On 03/10/2010 08:40 AM, Johann Cohen-Tanugi wrote: > Pauli, isn't it hopeless to follow the execution of the source code when > the crash actually occurs when I exit, and not when I execute. I would > have to understand enough of this umath_tests.c.src to spot a refcount > error or things like that

Re: [Numpy-discussion] crash at prompt exit after running test

2010-03-10 Thread Pauli Virtanen
Wed, 10 Mar 2010 15:40:04 +0100, Johann Cohen-Tanugi wrote: > Pauli, isn't it hopeless to follow the execution of the source code when > the crash actually occurs when I exit, and not when I execute. I would > have to understand enough of this umath_tests.c.src to spot a refcount > error or things

Re: [Numpy-discussion] Backwards slicing including the first element

2010-03-10 Thread Warren Weckesser
Jerome Esteve wrote: > Dear all, > > Is there a way to give an integer value to j when using a[i:j:-1] so > that the first element of the array can be included in the slice ? > > I would like to use some code like a[i:i-k:-1] to get a slice of > length k. > > The numpy documentation seems to sug

Re: [Numpy-discussion] crash at prompt exit after running test

2010-03-10 Thread Johann Cohen-Tanugi
Pauli, isn't it hopeless to follow the execution of the source code when the crash actually occurs when I exit, and not when I execute. I would have to understand enough of this umath_tests.c.src to spot a refcount error or things like that On 03/10/2010 03:11 PM, Pauli Virtanen wrote: > We

Re: [Numpy-discussion] crash at prompt exit after running test

2010-03-10 Thread Johann Cohen-Tanugi
http://projects.scipy.org/numpy/ticket/1425 for the bug trac well, I do feel challenged now... ;) J On 03/10/2010 03:11 PM, Pauli Virtanen wrote: > Wed, 10 Mar 2010 10:28:07 +0100, Johann Cohen-Tanugi wrote: > > >> On 03/10/2010 01:55 AM, Pauli Virtanen wrote: >> more fun : [c

Re: [Numpy-discussion] crash at prompt exit after running test

2010-03-10 Thread Pauli Virtanen
Wed, 10 Mar 2010 10:28:07 +0100, Johann Cohen-Tanugi wrote: > On 03/10/2010 01:55 AM, Pauli Virtanen wrote: >>> more fun : >>> [co...@jarrett tests]$ pwd >>> /home/cohen/sources/python/numpy/numpy/core/tests [co...@jarrett >>> tests]$ python -c 'import test_ufunc' python: Modules/gcmodule.c:277: >

Re: [Numpy-discussion] printing structured arrays

2010-03-10 Thread Bruce Schultz
On 10/03/10 10:09, Bruce Schultz wrote: > On Sat, Mar 6, 2010 at 8:35 AM, Gökhan Sever wrote: > >> On Fri, Mar 5, 2010 at 8:00 AM, Bruce Schultz >> wrote: >> >>> Output is: >>> ### ndarray >>> [[ 1. 2. ] >>> [ 3. 4.1]] >>> ### structured array >>> [(1.0, 2.0) (3.0, 4.09

[Numpy-discussion] How to apply a function to an ndarray over a given dimension

2010-03-10 Thread Jorge Scandaliaris
Hi, First, excuse me if I am over-optimizing, but I am curious if there exist a way to apply a function to an ndarray over a given dimension. In case I don't make myself clear, I have an array of shape( n,2,2) where each row represents a 2 by 2 covariance matrix, and I want to perform the eigenvalu

[Numpy-discussion] Backwards slicing including the first element

2010-03-10 Thread Jerome Esteve
Dear all, Is there a way to give an integer value to j when using a[i:j:-1] so that the first element of the array can be included in the slice ? I would like to use some code like a[i:i-k:-1] to get a slice of length k. The numpy documentation seems to suggest that j=-1 should work: "Assume

Re: [Numpy-discussion] crash at prompt exit after running test

2010-03-10 Thread Johann Cohen-Tanugi
On 03/10/2010 01:55 AM, Pauli Virtanen wrote: >> more fun : >> [co...@jarrett tests]$ pwd >> /home/cohen/sources/python/numpy/numpy/core/tests >> [co...@jarrett tests]$ python -c 'import test_ufunc' >> python: Modules/gcmodule.c:277: visit_decref: Assertion `gc->gc.gc_refs >> != 0' failed. >> Abo

Re: [Numpy-discussion] crash at prompt exit after running test

2010-03-10 Thread Johann Cohen-Tanugi
Ubuntu has a much shorter cycle of updates than Fedora, indeed. On 03/10/2010 06:27 AM, Charles R Harris wrote: On Tue, Mar 9, 2010 at 5:52 PM, Johann Cohen-Tanugi mailto:co...@lpta.in2p3.fr>> wrote: more fun : [co...@jarrett tests]$ pwd /home/cohen/sources/python/numpy/numpy/co