On Mon, Aug 8, 2011 at 10:54 AM, Olivier Delalleau <[email protected]> wrote:

> Hi,
>
> This is with numpy 1.6.1 under Linux x86_64, testing the upcast mechanism
> of "scalar + array":
>
> >>> import numpy; print (numpy.array(3, dtype=numpy.complex128) +
> numpy.ones(3, dtype=numpy.float32)).dtype
> complex64
>
> Since it has to upcast my array (float32 is not "compatible enough" with
> complex128), why does it upcast it to complex64 instead of complex128?
> As far as I can tell 1.4.x and 1.5.x versions of numpy are indeed upcasting
> to complex128.
>
>
The 0 dimensional array is being treated as a scalar, hence is cast to the
type of the 1d array. This seems more consistent with the idea that 0
dimensional arrays act like scalars, but I suppose that is open to
discussion.

Chuck
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to