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.])

But as you can see, I can only call the m.f function when I also pass
it the instance m again.
I really want to call it as
m.f( [-20,4,6] )
But then I get an error
ValueError: mismatch between python function inputs and received
arguments

Any ideas how to do this better?

Mark

_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to