[Numpy-discussion] round(numpy.float64(0.0)) is a numpy.float64

Nathaniel Smith njs at pobox.com
Mon Mar 26 21:24:49 EDT 2018


Even knowing that, it's still confusing that round(np.float64(0.0))
isn't the same as round(0.0). The reason is a Python 2 / Python 3
thing: in Python 2, round returns a float, while on Python 3, it
returns an integer – but numpy still uses the python 2 behavior
everywhere.

I'm not sure if it's possible or worthwhile to change this. If we'd
changed it when we first added python 3 support then it would have
been easy (and obviously a good idea), but at this point it might be
tricky?

-n

On Thu, Mar 22, 2018 at 12:32 PM, Nathan Goldbaum <nathan12343 at gmail.com> wrote:
> numpy.float is an alias to the python float builtin.
>
> https://github.com/numpy/numpy/issues/3998
>
>
> On Thu, Mar 22, 2018 at 2:26 PM Olivier <oc-spam66 at laposte.net> wrote:
>>
>> Hello,
>>
>>
>> Is it normal, expected and desired that :
>>
>>
>>       round(numpy.float64(0.0)) is a numpy.float64
>>
>>
>> while
>>
>>       round(numpy.float(0.0)) is an integer?
>>
>>
>> I find it disturbing and misleading. What do you think? Has it already
>> been
>> discussed somewhere else?
>>
>>
>> Best regards,
>>
>>
>> Olivier
>>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion at python.org
>> https://mail.python.org/mailman/listinfo/numpy-discussion
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>



-- 
Nathaniel J. Smith -- https://vorpus.org


More information about the NumPy-Discussion mailing list