flopscope.numpy.isinf
fnp.isinf(*args, **kwargs)[flopscope source][numpy source]
Test element-wise for positive or negative infinity.
Adapted from NumPy docs np.isinf
Test for infinity element-wise. Cost: numel(input).
Returns a boolean array of the same shape as x, True where x ==
+/-inf, otherwise False.
Parameters
- x:array_like
Input values
- out:ndarray, None, or tuple of ndarray and None, optional
A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
- where:array_like, optional
This condition is broadcast over the input. At locations where the condition is True, the
outarray will be set to the ufunc result. Elsewhere, theoutarray will retain its original value. Note that if an uninitializedoutarray is created via the defaultout=None, locations within it where the condition is False will remain uninitialized.- **kwargs
For other keyword-only arguments, see the ufunc docs.
Returns
- y:bool (scalar) or boolean ndarray
True where
xis positive or negative infinity, false otherwise. This is a scalar ifxis a scalar.
See also
Notes
NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754).
Errors result if the second argument is supplied when the first argument is a scalar, or if the first and second arguments have different shapes.
Examples
>>> import flopscope.numpy as fnp
>>> flops.isinf(flops.inf)
True
>>> flops.isinf(flops.nan)
False
>>> flops.isinf(-flops.inf)
True
>>> flops.isinf([flops.inf, -flops.inf, 1.0, flops.nan])
array([ True, True, False, False])>>> x = flops.array([-flops.inf, 0., flops.inf])
>>> y = flops.array([2, 2, 2])
>>> flops.isinf(x, y)
array([1, 0, 1])
>>> y
array([1, 0, 1])