Skip to content

Output type of round is inconsistent with python built-in #15297

@IAmS4n

Description

@IAmS4n

Based on official python doc, the output of round function is integer when ndigits is omitted. However, numpy does not follow this rule, and the output of rounded numpy still is a float. I think this behavior cause bugs!

Reproducing code example:

>>> for x in np.linspace(0,1,5):
...     print(round(x * 5.))
... 
0.0
1.0
2.0
4.0
5.0
>>> for x in map(float,np.linspace(0,1,5)):
...     print(round(x * 5.))
... 
0
1
2
4
5

Numpy/Python version information:

1.18.1 3.5.2 (default, Oct 8 2019, 13:06:37)
[GCC 5.4.0 20160609]

Metadata

Metadata

Assignees

No one assigned

    Labels

    00 - BugtriagedIssue/PR that was discussed in a triage meeting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions