[Numpy-discussion] reduce function of vectorize doesn't respect dtype?
T J
tjhnson@gmail....
Sat Aug 8 22:59:13 CDT 2009
On Fri, Aug 7, 2009 at 11:54 AM, T J<tjhnson@gmail.com> wrote:
> 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)
>
So is this a bug? Or am I doing something wrong? In the second example....
>>> d = b.ufunc.reduce(c)
>>> type(d[0])
<type 'int'>
>>> d.dtype
dtype('object')
More information about the NumPy-Discussion
mailing list