Re: [Numpy-discussion] Timing array construction

2009-04-29 Thread Eric Firing
Mark Janikas wrote: > Hello All, > > > > I was exploring some different ways to concatenate arrays, and using > “c_” is the fastest by far. Is there a difference I am missing that can > account for the huge disparity? Obviously the “zip” function makes the > “as array” and “array” calls sl

[Numpy-discussion] Timing array construction

2009-04-29 Thread Mark Janikas
Hello All, I was exploring some different ways to concatenate arrays, and using "c_" is the fastest by far. Is there a difference I am missing that can account for the huge disparity? Obviously the "zip" function makes the "as array" and "array" calls slower, but the same arguments (xCoords,

Re: [Numpy-discussion] Funky vectorisation question

2009-04-29 Thread Stéfan van der Walt
2009/4/30 David Warde-Farley : > Have you considered coding up a looped version in Cython? If this is > going to be a bottleneck then it would be very worthwhile. Stéfan's > code is clever, although as he points out, it will create an > intermediate array of size (len(I))**2, which may end up being

Re: [Numpy-discussion] Vectorizing array updates

2009-04-29 Thread Anne Archibald
2009/4/29 Dan Goodman : > Robert Kern wrote: >> On Wed, Apr 29, 2009 at 16:19, Dan Goodman wrote: >>> Robert Kern wrote: On Wed, Apr 29, 2009 at 08:03, Daniel Yarlett wrote: > As you can see, Current is different in the two cases. Any ideas how I > can recreate the behavio

Re: [Numpy-discussion] Funky vectorisation question

2009-04-29 Thread Dan Goodman
David Warde-Farley wrote: > On 29-Apr-09, at 5:49 PM, Dan Goodman wrote: > >> Thanks David, that's nice but unfortunately that Python loop will kill >> me. I'm thinking about some simulation code I'm writing where this >> operation will be carried out many, many times, with large arrays I. I >> fi

Re: [Numpy-discussion] Funky vectorisation question

2009-04-29 Thread Dan Goodman
Stéfan van der Walt wrote: > 2009/4/29 Dan Goodman : >> Here's the problem I want to write vectorised code for. I start with an >> array of indices, say I=array([0,1,0,2,0,1,4]), and I want to come up >> with an array C that counts how many times each index has been seen so >> far if you were count

Re: [Numpy-discussion] Funky vectorisation question

2009-04-29 Thread David Warde-Farley
On 29-Apr-09, at 5:49 PM, Dan Goodman wrote: > Thanks David, that's nice but unfortunately that Python loop will kill > me. I'm thinking about some simulation code I'm writing where this > operation will be carried out many, many times, with large arrays I. I > figure I need to keep the Python ove

Re: [Numpy-discussion] Vectorizing array updates

2009-04-29 Thread Dan Goodman
Robert Kern wrote: > On Wed, Apr 29, 2009 at 16:19, Dan Goodman wrote: >> Robert Kern wrote: >>> On Wed, Apr 29, 2009 at 08:03, Daniel Yarlett >>> wrote: >>> As you can see, Current is different in the two cases. Any ideas how I can recreate the behavior of the iterative process in a m

Re: [Numpy-discussion] Vectorizing array updates

2009-04-29 Thread Robert Kern
On Wed, Apr 29, 2009 at 16:19, Dan Goodman wrote: > Robert Kern wrote: >> On Wed, Apr 29, 2009 at 08:03, Daniel Yarlett >> wrote: >> >>> As you can see, Current is different in the two cases. Any ideas how I >>> can recreate the behavior of the iterative process in a more numpy- >>> friendly, ve

Re: [Numpy-discussion] Funky vectorisation question

2009-04-29 Thread Dan Goodman
David Warde-Farley wrote: > On 29-Apr-09, at 5:06 PM, Dan Goodman wrote: > >> Here's the problem I want to write vectorised code for. I start with >> an >> array of indices, say I=array([0,1,0,2,0,1,4]), and I want to come up >> with an array C that counts how many times each index has been seen

Re: [Numpy-discussion] Funky vectorisation question

2009-04-29 Thread Stéfan van der Walt
2009/4/29 Dan Goodman : > Here's the problem I want to write vectorised code for. I start with an > array of indices, say I=array([0,1,0,2,0,1,4]), and I want to come up > with an array C that counts how many times each index has been seen so > far if you were counting through the array from the be

Re: [Numpy-discussion] Funky vectorisation question

2009-04-29 Thread David Warde-Farley
On 29-Apr-09, at 5:06 PM, Dan Goodman wrote: > Here's the problem I want to write vectorised code for. I start with > an > array of indices, say I=array([0,1,0,2,0,1,4]), and I want to come up > with an array C that counts how many times each index has been seen so > far if you were counting th

Re: [Numpy-discussion] Vectorizing array updates

2009-04-29 Thread Dan Goodman
Robert Kern wrote: > On Wed, Apr 29, 2009 at 08:03, Daniel Yarlett > wrote: > >> As you can see, Current is different in the two cases. Any ideas how I >> can recreate the behavior of the iterative process in a more numpy- >> friendly, vectorized (and hopefully quicker) way? > > Use bincount().

[Numpy-discussion] Funky vectorisation question

2009-04-29 Thread Dan Goodman
Hi all, Here's the problem I want to write vectorised code for. I start with an array of indices, say I=array([0,1,0,2,0,1,4]), and I want to come up with an array C that counts how many times each index has been seen so far if you were counting through the array from the beginning to the end,

Re: [Numpy-discussion] Vectorizing array updates

2009-04-29 Thread Robert Kern
On Wed, Apr 29, 2009 at 08:03, Daniel Yarlett wrote: > As you can see, Current is different in the two cases. Any ideas how I > can recreate the behavior of the iterative process in a more numpy- > friendly, vectorized (and hopefully quicker) way? Use bincount(). > And possibly also > about why

Re: [Numpy-discussion] Vectorizing array updates

2009-04-29 Thread Dan Goodman
> As you can see, Current is different in the two cases. Any ideas how I > can recreate the behavior of the iterative process in a more numpy- > friendly, vectorized (and hopefully quicker) way? And possibly also > about why my intuitions concerning the semantics of the vectorized > code are

Re: [Numpy-discussion] Arithmetic on arrays of pointers

2009-04-29 Thread Dan Goodman
Thanks Chris and Stefan, In the end, I'm going to take both your advice and not do this after all. Actually I worked out another way to do the same thing. Essentially, rather than store a pointer I store a reference to the array, and an array of indices in that array. Much safer and the things

Re: [Numpy-discussion] Arithmetic on arrays of pointers

2009-04-29 Thread Christopher Barker
Dan Goodman wrote: > (because I want to construct the 1D arrays X, Y above from values picked > from a variety of possible data structures, including dense and sparse > 2D arrays, but in such a way that the code that uses these values > doesn't have to know where the values came from in these da

Re: [Numpy-discussion] Creating a RGB-image from BW

2009-04-29 Thread Johannes Bauer
Hi Zach, Zachary Pincus schrieb: > According to http://www.pygtk.org/pygtk2reference/class- > gdkpixbuf.html , the pixels_array is a numeric python array (a > predecessor to numpy). The upshot is that perhaps the nice > broadcasting machinery will work fine: > > pb_pixels[...] = fits_pixels

Re: [Numpy-discussion] setterr question

2009-04-29 Thread Robin
2009/4/29 Stéfan van der Walt : > 2009/4/29 Robin : >> I have been using seterr to try to catch where Nans are appearing in >> my analysis. >> >> I used all: 'warn' which worked the first time I ran the function, but >> as specified in the documentation it only warns 'once only'. Is there >> a way

Re: [Numpy-discussion] MemoryError for computing eigen-vector on 10, 000*10, 000 matrix

2009-04-29 Thread Zhenxin Zhan
Most of the time, it just needs the largest or smallest eigenvalues/vectors. But unfortunately, it needs more. Thanks. 2009-04-29 Zhenxin Zhan 发件人: Sebastian Walter 发送时间: 2009-04-29 02:17:38 收件人: Discussion of Numerical Python 抄送: 主题: Re: [Numpy-discussion] MemoryError for computin

Re: [Numpy-discussion] setterr question

2009-04-29 Thread Stéfan van der Walt
2009/4/29 Robin : > I have been using seterr to try to catch where Nans are appearing in > my analysis. > > I used all: 'warn' which worked the first time I ran the function, but > as specified in the documentation it only warns 'once only'. Is there > a way I can reset the count so it will warn ag

Re: [Numpy-discussion] MemoryError for computing eigen-vect or on 10,000*10, 000 matrix

2009-04-29 Thread Zhenxin Zhan
It's kind of characterizing the dynamics of virus spreading in arbitrary networks. It uses Markov knowledge. There are a lot of complicated mathmatics equations. 2009-04-29 Zhenxin Zhan 发件人: Charles R Harris 发送时间: 2009-04-29 02:09:57 收件人: Discussion of Numerical Python 抄送: 主题: Re:

[Numpy-discussion] setterr question

2009-04-29 Thread Robin
Hi, I have been using seterr to try to catch where Nans are appearing in my analysis. I used all: 'warn' which worked the first time I ran the function, but as specified in the documentation it only warns 'once only'. Is there a way I can reset the count so it will warn again, without loosing my

[Numpy-discussion] Vectorizing array updates

2009-04-29 Thread Daniel Yarlett
Hi All, I'm coding an iterative algorithm which needs to update a results array on each iteration. I have several (one-dimensional) arrays, and currently I have the following non-vectorized code which gets called at the end of each iteration (Inds, Current, and Update are all one- dimension

Re: [Numpy-discussion] [SciPy-user] Managing Python with NumPy and many external libraries on multiple Windows machines

2009-04-29 Thread David Cournapeau
Stéfan van der Walt wrote: > > I see a number of docstrings already have > > .. versionadded:: 1.3.0 > Yes, but I don't think it is enough. In particular, I don't like so much the fact that the C API documentation for every function is separate from the code. There are several mismatches betwee

Re: [Numpy-discussion] Arithmetic on arrays of pointers

2009-04-29 Thread Stéfan van der Walt
Hi Dan 2009/4/29 Dan Goodman : > I have a slightly strange idea for something I would like to do with > numpy which I guess probably doesn't exist, but I may be wrong. What I > want to do, essentially, is to have two arrays of equal size, say X and > Y, of pointers to doubles say. Then I want to d

Re: [Numpy-discussion] MemoryError for computing eigen-vector on 10, 000*10, 000 matrix

2009-04-29 Thread Sebastian Walter
+1 to that Often, one is only interested in the largest or smallest eigenvalues/vectors of a problem. Then the method of choice are iterative solvers, e.g. Lanczos algorithm. If only the largest eigenvalue/vector is needed, you could try the power iteration. On Wed, Apr 29, 2009 at 7:49 AM, Zh

Re: [Numpy-discussion] [SciPy-user] Managing Python with NumPy and many external libraries on multiple Windows machines

2009-04-29 Thread Stéfan van der Walt
2009/4/29 David Cournapeau : > Stéfan van der Walt wrote: >> We can already do this: simply choose a convention for NPY_VERSION and >> NPY_FEATURE_VERSION so that they are related. > > By tracking, I meant more than just the actual number in the source > code, like something in the documentation. S

Re: [Numpy-discussion] MemoryError for computing eigen-vector on 10, 000*10, 000 matrix

2009-04-29 Thread Charles R Harris
On Tue, Apr 28, 2009 at 11:49 PM, Zhenxin Zhan wrote: > Thanks. My mistake. > > The os is 32-bit. I am doing a network-simulation for my teacher. The > average degree of the network topology is about 6.0. So I think it is > sparse. > > The paper needs the eigen values and the eigen vectors which