mindspore.numpy.rint

View Source On Gitee
mindspore.numpy.rint(x, dtype=None)[source]

Rounds elements of the array to the nearest integer.

Note

Numpy arguments out, where, casting, order, subok, signature, and extobj are not supported.

Parameters
Returns

Output tensor is same shape and type as x. This is a scalar if x is a scalar.

Raises

TypeError – If x can not be converted to tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore.numpy as np
>>> x = np.array([-1.7, -1.5, 0.2, 1.5, 1.7, 2.0])
>>> print(np.rint(x))
[-2. -2. 0. 2. 2. 2.]