Hi Mark On Wed, Aug 08, 2007 at 03:37:09PM -0000, 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 > if y > self.x: rv = y > return rv > f = vectorize(func) > > > >>> m = test() > >>> m.f( m, [-20,4,6] ) > array([ 3., 4., 6.])
Maybe you don't need to use vectorize. How about def func(self,y): y = y.copy() y[y <= self.x] = self.x return y Cheers Stéfan _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion