[Numpy-discussion] Output type of round is inconsistent with python built-in

Robert Kern robert.kern at gmail.com
Wed Feb 26 18:07:57 EST 2020


On Wed, Feb 26, 2020 at 5:27 PM <josef.pktd at gmail.com> wrote:

> great another object array
>
> np.asarray([round(x_i.item()) for x_i in np.array([1, 2.5, 2e20, 2e200])])
> array([1, 2, 200000000000000000000,
>
>  199999999999999993946624442502072331894900655091004725296483501900693696871108151068392676809412503736055024831947764816364271468736556969278770082094479755742047182133579963622363626612334257709776896],
>       dtype=object)
>
>
> I would rather have numpy consistent with numpy than with python
>

Since round() (and the __round__() interface) is part of Python and not
numpy, there is nothing in numpy to be consistent with. We only implement
__round__() for the scalar types.

-- 
Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20200226/a605b87f/attachment.html>


More information about the NumPy-Discussion mailing list