numpy.isinf¶

numpy.isinf(x[, out])

Shows which elements of the input are positive or negative infinity. Returns a numpy boolean scalar or array resulting from an element-wise test for positive or negative infinity.

Parameters: x : array_like input values y : array_like, optional An array with the same shape as x to store the result. y : {ndarray, bool} For scalar input data, the result is a new numpy boolean with value True if the input data is positive or negative infinity; otherwise the value is False. For array input data, the result is an numpy boolean array with the same dimensions as the input and the values are True if the corresponding element of the input is positive or negative infinity; otherwise the values are False. If the second argument is supplied then an numpy integer array is returned with values 0 or 1 corresponding to False and True, respectively.

isneginf
Shows which elements are negative infinity.
isposinf
Shows which elements are positive infinity.
isnan
Shows which elements are Not a Number (NaN).
isfinite
Shows which elements are not: Not a number, positive and negative infinity

Notes

Numpy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754). This means that Not a Number is not equivalent to infinity. Also that positive infinity is not equivalent to negative infinity. But infinity is equivalent to positive infinity.

Errors result if second argument is also supplied with scalar input or if first and second arguments have different shapes.

Numpy’s definitions for positive infinity (PINF) and negative infinity (NINF) may be change in the future versions.

Examples

```>>> np.isinf(np.inf)
True
>>> np.isinf(np.nan)
False
>>> np.isinf(np.NINF)
True
>>> np.isinf([np.inf, -np.inf, 1.0, np.nan])
array([ True,  True, False, False], dtype=bool)
>>> x=np.array([-np.inf, 0., np.inf])
>>> y=np.array([2,2,2])
>>> np.isinf(x,y)
array([1, 0, 1])
>>> y
array([1, 0, 1])
```

numpy.isfinite

numpy.isnan