[SciPy-user] vectorizing a function inside a class
morovia morovia
jallikattu@googlemail....
Tue Sep 4 00:46:35 CDT 2007
Hello all,
I am trying to vectorize a function which resides in the class.
Can any one help me out ? I have appended the test code below.
from scipy import vectorize
************************************************
def square(x):
return x.x
v_sq = vectorize(square)
result = v_sq(x)
************************************************
Just new to class !!
I just want to mimic the above function,
which works. But, inside the class structure,
it does not !
from scipy import vectorize
class a:
def __init__(self,x):
self.x = x
def square(self):
return self.x*self.x
def v_sq(self):
vect_sq = vectorize(square)
return vect_sq(self)
x = [1,2,3]
fn = a(x)
fn.v_sq()
Thanks in advance,
Morovia.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20070904/a9f4e41a/attachment.html
More information about the SciPy-user
mailing list