dpnp.round
- dpnp.round(x, decimals=0, out=None, dtype=None)
Rounds each element x_i of the input array x to the nearest integer-valued number.
When two integers are equally close to x_i, the result is the nearest even integer to x_i.
For full documentation refer to
numpy.round
.- Parameters:
x ({dpnp.ndarray, usm_ndarray}) -- Input array, expected to have numeric data type.
decimals (int, optional) -- Number of decimal places to round to (default: 0). If decimals is negative, it specifies the number of positions to the left of the decimal point.
out ({None, dpnp.ndarray, usm_ndarray}, optional) -- Output array to populate. Array must have the correct shape and the expected data type. Default:
None
.
- Returns:
out -- An array containing the element-wise rounded values.
- Return type:
dpnp.ndarray
See also
dpnp.around
Equivalent function; see for details.
dpnp.ndarray.round
Equivalent function.
dpnp.rint
Round elements of the array to the nearest integer.
dpnp.ceil
Compute the ceiling of the input, element-wise.
dpnp.fix
Round to nearest integer towards zero, element-wise.
dpnp.floor
Return the floor of the input, element-wise.
dpnp.trunc
Return the truncated value of the input, element-wise.
Examples
>>> import dpnp as np >>> np.round(np.array([0.37, 1.64])) array([0., 2.]) >>> np.round(np.array([0.37, 1.64]), decimals=1) array([0.4, 1.6]) >>> np.round(np.array([.5, 1.5, 2.5, 3.5, 4.5])) # rounds to nearest even value array([0., 2., 2., 4., 4.]) >>> np.round(np.array([1, 2, 3, 11]), decimals=1) # ndarray of ints is returned array([ 1, 2, 3, 11]) >>> np.round(np.array([1, 2, 3, 11]), decimals=-1) array([ 0, 0, 0, 10])