I have the following question concerning universal functions in numpy. How can I define a universal function which returns the same type of numpy array as the numpy build-in functions. The following sample code:
import numpy as np
def mysimplefunc(a):
return np.sin(a)
mysimpleufunc = np.frompyfunc(mysimplefunc,1,1)
a = np.linspace(0.0,1.0,3)
print(np.sin(a).dtype)
print(mysimpleufunc(a).dtype)
results in the output:
float64
object
Any help is very much appreciated :)
PS.: I am using python 3.4