[Numpy-discussion] Integers to integer powers, let's make a decision

Antoine Pitrou solipsis at pitrou.net
Mon Jun 13 10:42:51 EDT 2016


On Mon, 13 Jun 2016 10:05:08 -0400
Alan Isaac <alan.isaac at gmail.com> wrote:
> 
> That is a misunderstanding, which may be influencing the discussion.
> Examples of complications:
> 
>  >>> type(np.int8(2)**2)
> <type 'numpy.int32'>
>  >>> type(np.uint64(2)**np.int8(2))
> <type 'numpy.float64'>

The `uint64 x int8 -> float64` is IMHO an abberration in Numpy's
typing logic. Regardless, it's not specific to the power operator:

>>> np.int64(2) + np.int32(3)
5
>>> np.uint64(2) + np.int32(3)
5.0

The other complications have to do with the type width, which are less
annoying than changing the numeric kind altogether (as would be done by
mandating int x int -> float in all cases).

Regards

Antoine.





More information about the NumPy-Discussion mailing list