rint¶
-
rint(x, out=None, **kwargs)¶ Round elements of the array to the nearest integer.
Parameters: - x : ndarray or scalar
Input array.
- out : ndarray or None
A location into which the result is stored. If provided, it must have the same shape and type as the input. If not provided or None, a freshly-allocated array is returned.
Returns: - out : ndarray or scalar
Output array is same shape and type as x. This is a scalar if x is a scalar.
Notes
This function differs from the original numpy.rint in the following way(s): - only ndarray or scalar is accpted as valid input, tuple of ndarray is not supported - broadcasting to out of different shape is currently not supported - when input is plain python numerics, the result will not be stored in the out param
Examples
>>> a = np.array([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0]) >>> np.rint(a) array([-2., -2., -0., 0., 1., 2., 2.])