mindspore.numpy.isfinite

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

Tests element-wise for finiteness (not infinity or not Not a Number).

The result is returned as a boolean array.

Note

Numpy arguments out, where, casting, order, subok, signature, and extobj are not supported. On GPU, the supported dtypes are np.float16, and np.float32.

Parameters
  • x (Tensor) – Input values.

  • dtype (mindspore.dtype, optional) – Default: None . Overrides the dtype of the output Tensor.

Returns

Tensor or scalar, true where x is not positive infinity, negative infinity, or NaN; false otherwise. This is a scalar if x is a scalar.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore.numpy as np
>>> output = np.isfinite(np.array([np.inf, 1., np.nan]).astype('float32'))
>>> print(output)
[False  True False]