I am having some problems with the numpy.vectorize function.
I have defined a function that works well for single element input but the vectorized version returns different results - What am I doing wrong?
Code:
def c_inf_comp(z):
if z>0:
return np.exp(-1./(z*z))
else:
return 0
>>> x = np.array([-10., 10.])
>>> x
array([-10., 10.])
>>> c_inf_comp(x[0])
0
>>> c_inf_comp(x[1])
0.99004983374916811
>>> vfunz = np.vectorize(c_inf_comp)
>>> vfunz(x)
array([0, 0])