[Numpy-discussion] reduce function of vectorize doesn't respect dtype?
T J
tjhnson@gmail....
Fri Aug 7 13:54:24 CDT 2009
The reduce function of ufunc of a vectorized function doesn't seem to
respect the dtype.
>>> def a(x,y): return x+y
>>> b = vectorize(a)
>>> c = array([1,2])
>>> b(c, c) # use once to populate b.ufunc
>>> d = b.ufunc.reduce(c)
>>> c.dtype, type(d)
dtype('int32'), <type 'int'>
>>> c = array([[1,2,3],[4,5,6]])
>>> b.ufunc.reduce(c)
array([5, 7, 9], dtype=object)
My goal is to use the output of vectorize() as if it is actually a ufunc.
So I'd really like to just type: b.reduce, b.accumulate, etc.
And I don't want to have to write (after using it once to populate b.ufunc):
b.ufunc.reduce(c).astype(numpy.int32)
More information about the NumPy-Discussion
mailing list