Re: [Numpy-discussion] vectorized function inside a class

2007-08-08 Thread Anne Archibald
On 08/08/2007, mark <[EMAIL PROTECTED]> wrote: > Thanks for the ideas to circumvent vectorization. > But the real function I need to vectorize is quite a bit more > complicated. > So I would really like to use vectorize. > Are there any reasons against vectorization? Is it slow? > The way Tim sugge

Re: [Numpy-discussion] vectorized function inside a class

2007-08-08 Thread mark
Thanks for the ideas to circumvent vectorization. But the real function I need to vectorize is quite a bit more complicated. So I would really like to use vectorize. Are there any reasons against vectorization? Is it slow? The way Tim suggests I expect to be slow as there are two functions calls. T

Re: [Numpy-discussion] vectorized function inside a class

2007-08-08 Thread Stefan van der Walt
On Wed, Aug 08, 2007 at 08:54:18AM -0700, Timothy Hochberg wrote: > Don't use vectorize? Something like: > > def f(self,y): > return np.where(y > self.x, y, self.x) A one-liner, cool. Benchmarks on some other methods: Method 1: N.where 100 loops, best of 3: 9.32 ms per loop Method 2: N.cl

Re: [Numpy-discussion] vectorized function inside a class

2007-08-08 Thread Timothy Hochberg
On 8/8/07, mark <[EMAIL PROTECTED]> wrote: > > I am trying to figure out a way to define a vectorized function inside > a class. > This is what I tried: > > class test: > def __init__(self): > self.x = 3.0 > def func(self,y): > rv = self.x >

Re: [Numpy-discussion] vectorized function inside a class

2007-08-08 Thread Stefan van der Walt
Hi Mark On Wed, Aug 08, 2007 at 03:37:09PM -, mark wrote: > I am trying to figure out a way to define a vectorized function inside > a class. > This is what I tried: > > class test: > def __init__(self): > self.x = 3.0 > def func(self,y): > rv = self.x

[Numpy-discussion] vectorized function inside a class

2007-08-08 Thread mark
I am trying to figure out a way to define a vectorized function inside a class. This is what I tried: class test: def __init__(self): self.x = 3.0 def func(self,y): rv = self.x if y > self.x: rv = y return rv f