numpy.frompyfunc
can only produce ufuncs with object dtype output, but ufunc.accumulate
defaults to using the input dtype as the dtype for intermediate results. (That, or the dtype of the out
array if you provide one, but you didn't provide one.) When you pass in an array of float64 dtype, ufunc.accumulate
looks for a ufunc loop with float64 output, and it doesn't find one.
You can pass in an array of object dtype, like np.array([0, 1, 1, 0, 0, 0.0], dtype=np.object_)
, or you can override the default intermediate dtype with leaku.accumulate(np.array([0, 1, 1, 0, 0, 0.0]), dtype=np.object_)
.
Note that numpy.frompyfunc
ufuncs are as slow as any other Python-level code, not "NumPy speed", and object arrays have much worse speed and memory characteristics than normal arrays, as well as other inconvenient behavior. I wouldn't recommend using numpy.frompyfunc
. Consider using Numba instead.