[Numpy-discussion] Numpy integers to integer powers again again

Charles R Harris charlesr.harris at gmail.com
Wed Oct 26 15:58:20 EDT 2016


On Wed, Oct 26, 2016 at 1:39 PM, Nathaniel Smith <njs at pobox.com> wrote:

> On Wed, Oct 26, 2016 at 12:23 PM, Charles R Harris
> <charlesr.harris at gmail.com> wrote:
> [...]
> > What I have been concerned about are the follow combinations that
> currently
> > return floats
> >
> > num: <type 'numpy.int8'>, exp: <type 'numpy.int8'>, res: <type
> > 'numpy.float32'>
> > num: <type 'numpy.int16'>, exp: <type 'numpy.int8'>, res: <type
> > 'numpy.float32'>
> > num: <type 'numpy.int16'>, exp: <type 'numpy.int16'>, res: <type
> > 'numpy.float32'>
> > num: <type 'numpy.int32'>, exp: <type 'numpy.int8'>, res: <type
> > 'numpy.float64'>
> > num: <type 'numpy.int32'>, exp: <type 'numpy.int16'>, res: <type
> > 'numpy.float64'>
> > num: <type 'numpy.int32'>, exp: <type 'numpy.int32'>, res: <type
> > 'numpy.float64'>
> > num: <type 'numpy.int64'>, exp: <type 'numpy.int8'>, res: <type
> > 'numpy.float64'>
> > num: <type 'numpy.int64'>, exp: <type 'numpy.int16'>, res: <type
> > 'numpy.float64'>
> > num: <type 'numpy.int64'>, exp: <type 'numpy.int32'>, res: <type
> > 'numpy.float64'>
> > num: <type 'numpy.int64'>, exp: <type 'numpy.int64'>, res: <type
> > 'numpy.float64'>
> > num: <type 'numpy.int64'>, exp: <type 'numpy.int64'>, res: <type
> > 'numpy.float64'>
> > num: <type 'numpy.uint64'>, exp: <type 'numpy.int8'>, res: <type
> > 'numpy.float64'>
> > num: <type 'numpy.uint64'>, exp: <type 'numpy.int16'>, res: <type
> > 'numpy.float64'>
> > num: <type 'numpy.uint64'>, exp: <type 'numpy.int32'>, res: <type
> > 'numpy.float64'>
> > num: <type 'numpy.uint64'>, exp: <type 'numpy.int64'>, res: <type
> > 'numpy.float64'>
> > num: <type 'numpy.uint64'>, exp: <type 'numpy.int64'>, res: <type
> > 'numpy.float64'>
>
> What's this referring to? For both arrays and scalars I get:
>
> In [8]: (np.array(2, dtype=np.int8) ** np.array(2, dtype=np.int8)).dtype
> Out[8]: dtype('int8')
>
> In [9]: (np.int8(2) ** np.int8(2)).dtype
> Out[9]: dtype('int8')
>
>
You need a negative exponent to see the effect.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20161026/7cf79b8d/attachment.html>


More information about the NumPy-Discussion mailing list