Closed
Description
The semantics of round() changed in Python 3:
round(number[, ndigits])
Return number rounded to ndigits precision after the decimal point. If ndigits is omitted or is None, it returns the nearest integer to its input.
This works incorrectly in the case of np.float64, which returns a float. I believe the __round__ method is calling __rint__, which should return an integer but doesn't.
Reproducing code example:
import numpy as np
In [50]: round(1.0)
Out[50]: 1
In [51]: round(float(1.0))
Out[51]: 1
In [52]: round(np.float(1.0))
Out[52]: 1
In [53]: round(np.float64(1.0))
Out[53]: 1.0
This behavior is the same for float16, float32, and float128.
Metadata
Metadata
Assignees
Labels
No labels