[Numpy-discussion] Inconsistent output dtype in mixed scalar-array operations

Olivier Delalleau shish at keba.be
Tue May 10 13:16:13 EDT 2011


Hi,

I opened a ticket about this (http://projects.scipy.org/numpy/ticket/1827),
but thought I'd also ask on the mailing list whether this is working as
intended.

It looks like the resulting dtype of a "+" operation between a scalar and an
array can depend on the order of the arguments. This seems wrong.

Tested with numpy 1.5.1 under Ubuntu 11.04 (64-bit).

In [4]: (numpy.array(0, dtype='uint16') + numpy.array([1],
dtype='int8')).dtype
Out[4]: dtype('int16')

In [6]: (numpy.array([1], dtype='int8') + numpy.array(0,
dtype='uint16')).dtype
Out[6]: dtype('int8')

Thanks for any feedback,

-=- Olivier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110510/5a4b280f/attachment.html>


More information about the NumPy-Discussion mailing list