For generating Numpy indexes, I need to round a float
to an int
.
In Python 2.7, rounding a float
gives a float
:
>>> round(2.7)
3.0
In Python 3.5, an int
is returned:
>>> round(2.7)
3
np.round()
always returns a float.
Is int(round(2.7))
the canonical approach to round to an integer in a Python 2/3 compatible way?