Re: [Numpy-discussion] slow numpy.clip ?

2006-12-18 Thread Eric Firing
David Cournapeau wrote: > Eric Firing wrote: >> David, >> >> I think my earlier post got lost in the exchange between you and Stefan, >> so I will reiterate the central point: numpy.clip *is* slow, in that an >> implementation using putmask is substantially faster: >> >> def fastclip(a, vmin, vma

[Numpy-discussion] Profiling numpy ? (parts written in C)

2006-12-18 Thread David Cournapeau
Hi, Following the discussion on clip and other functions which *may* be slow in numpy, I would like to know if there is a way to easily profile numpy, ie functions which are written in C. For example, I am not sure to understand why a function like take(a, b) with a a double 256x4 array a

Re: [Numpy-discussion] slow numpy.clip ?

2006-12-18 Thread Gael Varoquaux
On Tue, Dec 19, 2006 at 02:10:29PM +0900, David Cournapeau wrote: > I would really like to see the imshow/show calls goes in the range of a > few hundred ms; for interactive plotting, this really change a lot in my > opinion. I think this is strongly dependant on some parameters. I did some inte

Re: [Numpy-discussion] slow numpy.clip ?

2006-12-18 Thread David Cournapeau
Eric Firing wrote: > David, > > I think my earlier post got lost in the exchange between you and Stefan, > so I will reiterate the central point: numpy.clip *is* slow, in that an > implementation using putmask is substantially faster: > > def fastclip(a, vmin, vmax): > a = a.copy() >

Re: [Numpy-discussion] sum of two arrays with different shape?

2006-12-18 Thread Robert Kern
zhang yunfeng wrote: > Yes, It seems powerful. But If > one happened to add two incompatible array by > mistake, Does the result make sense? It may. The array object can't read your mind and know that you didn't intend it to do what you (accidentally) told it to do. > May be the broadcast feat

Re: [Numpy-discussion] sum of two arrays with different shape?

2006-12-18 Thread zhang yunfeng
2006/12/18, Robert Kern <[EMAIL PROTECTED]>: zhang yunfeng wrote: > Hi, I'm newbie to Numpy. > > When reading tutorials at > http://www.scipy.org/Tentative_NumPy_Tutorial > , I found a snippet about > addition of two arrays with different shape, Doe

Re: [Numpy-discussion] slow numpy.clip ?

2006-12-18 Thread Eric Firing
David, I think my earlier post got lost in the exchange between you and Stefan, so I will reiterate the central point: numpy.clip *is* slow, in that an implementation using putmask is substantially faster: def fastclip(a, vmin, vmax): a = a.copy() putmask(a, a<=vmin, vmin)

Re: [Numpy-discussion] Subclasses - use of __finalize__

2006-12-18 Thread Pierre GM
On Saturday 16 December 2006 19:55, Colin J. Williams wrote: Colin, First of all, a disclaimer: I'm a (bad) hydrologist, not a computer scientist. I learned python/numpy by playing around, and really got into subclassing since 3-4 months ago. My explanations might not be completely accurate, I'

Re: [Numpy-discussion] Python 2.5 on win and Gnuplot and alter code1

2006-12-18 Thread Alan G Isaac
On Mon, 18 Dec 2006, Francesc Altet apparently wrote to Hermann: > Do you have a special need to use Gnuplot? As it requires > Numeric and because it has issues with python2.5 and is > not maintained anymore, I don't recommend you using it any > longer. Have you tried SVN? My recollection is

Re: [Numpy-discussion] Unexpected output usingnumpy.ndarray and__radd__

2006-12-18 Thread Mark Hoffmann
Excellent, thank you - it solved the problem! /Mark -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tim Hochberg Sent: 18. december 2006 14:06 To: Discussion of Numerical Python Subject: Re: [Numpy-discussion] Unexpected output usingnumpy.ndarray and__ra

Re: [Numpy-discussion] Unexpected output using numpy.ndarray and__radd__

2006-12-18 Thread Tim Hochberg
Mark Hoffmann wrote: > I appreciate the answer and the solution suggestion. I see that it is > possible to make a work around by subclassing from ndarray. Still, in the > "print a+c" statement, I don't understand why a.__add__(c) doesn't return > NotImplemented (because ndarray shouldn't recogni

Re: [Numpy-discussion] Unexpected output using numpy.ndarray and__radd__

2006-12-18 Thread Mark Hoffmann
I appreciate the answer and the solution suggestion. I see that it is possible to make a work around by subclassing from ndarray. Still, in the "print a+c" statement, I don't understand why a.__add__(c) doesn't return NotImplemented (because ndarray shouldn't recognize the Cyclehist class) and

Re: [Numpy-discussion] Python 2.5 on win and Gnuplot and alter_code1

2006-12-18 Thread hermann.ruckerbauer
Thanks for the feedback, The reason why I'm trying to use Gnuplot is, that I got quite some old scripts with Gnuplot that i would like to reuse. Everything I create now is matplotlib based ... This is working fine in my config. Regards Hermann Hermann Ruckerbauer Module D

Re: [Numpy-discussion] Python 2.5 on win and Gnuplot and alter_code1

2006-12-18 Thread Francesc Altet
El dl 18 de 12 del 2006 a les 11:44 +0100, en/na [EMAIL PROTECTED] va escriure: > Hello *, > > Sorry for this maybe stupid question, I might still miss some > understanding of pyton or other stuff ... > > I have problems getting Gnuplot running under python 2.5 on Windows. Do you have a special

[Numpy-discussion] Python 2.5 on win and Gnuplot and alter_code1

2006-12-18 Thread hermann.ruckerbauer
Hello *, Sorry for this maybe stupid question, I might still miss some understanding of pyton or other stuff ... I have problems getting Gnuplot running under python 2.5 on Windows. My understanding is, that Gnuplot requires Numeric. Unfortionally there is only a numeric for python 2.4 availabl

Re: [Numpy-discussion] slow numpy.clip ?

2006-12-18 Thread David Cournapeau
Stefan van der Walt wrote: > On Mon, Dec 18, 2006 at 05:45:09PM +0900, David Cournapeau wrote: >> Yes, I of course mistyped the < and the copy. But the function is still >> moderately faster on my workstation: >> >> ncalls tottime percall cumtime percall filename:lineno(function) >>

Re: [Numpy-discussion] Unexpected output using numpy.ndarray and __radd__

2006-12-18 Thread Stefan van der Walt
Hi Mark On Mon, Dec 18, 2006 at 08:30:20AM +0100, Mark Hoffmann wrote: > The following issue has puzzled me for a while. I want to add a numpy.ndarray > and an instance of my own class. I define this operation by implementing the > methods __add__ and __radd__. My programme (including output) look

Re: [Numpy-discussion] slow numpy.clip ?

2006-12-18 Thread Stefan van der Walt
On Mon, Dec 18, 2006 at 05:45:09PM +0900, David Cournapeau wrote: > Yes, I of course mistyped the < and the copy. But the function is still > moderately faster on my workstation: > > ncalls tottime percall cumtime percall filename:lineno(function) > 10.0030.0033.9443

Re: [Numpy-discussion] slow numpy.clip ?

2006-12-18 Thread David Cournapeau
Stefan van der Walt wrote: > Hi David > > The benchmark below isn't quite correct. In clip2_bench the data is > effectively only clipped once. I attach a slightly modified version, > for which the benchmark results look like this: Yes, I of course mistyped the < and the copy. But the function is

Re: [Numpy-discussion] slow numpy.clip ?

2006-12-18 Thread Stefan van der Walt
Hi David The benchmark below isn't quite correct. In clip2_bench the data is effectively only clipped once. I attach a slightly modified version, for which the benchmark results look like this: 4 function calls in 4.631 CPU seconds Ordered by: cumulative time ncalls tottime percall

Re: [Numpy-discussion] slow numpy.clip ?

2006-12-18 Thread Eric Firing
David Cournapeau wrote: Hi, When trying to speed up some matplotlib routines with the matplotlib dev team, I noticed that numpy.clip is pretty slow: clip(data, m, M) is slower than a direct numpy implementation (that is data[datadata[data>M] = M; return data.copy()). My understanding is th