w3resource

NumPy Logic functions: isposinf() function

numpy.isposinf() function

The isposinf() function is used to test element-wise for positive infinity, return result as bool array.

Syntax:

numpy.isposinf(x, out=None)

Version: 1.15.0

Parameter:

Name Description Required /
Optional
x The input array.
array_like
Required
y A boolean array with the same shape as x to store the result.
array_like
Optional

Returns:
out : ndarray - A boolean array with the same dimensions as the input.
If second argument is not supplied then a boolean array is returned with values True where the corresponding
element of the input is positive infinity and values False where the element of the input is not positive infinity.
If a second argument is supplied the result is stored there. If the type of that array is a numeric type the result
is represented as zeros and ones, if the type is boolean then as False and True.
The return value out is then a reference to that array.

Notes:
NumPy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754).

Errors result if the second argument is also supplied when x is a scalar input,
or if first and second arguments have different shapes.

NumPy.isposinf() method Example-1:

>>> import numpy as np
>>> np.isposinf(np.PINF)

Output:

True

NumPy.isposinf() method Example-2:

>>> import numpy as np
>>> np.isposinf(np.inf)

Output:

True

NumPy.isposinf() method Example-3:

>>> import numpy as np
>>> np.isposinf(np.NINF)

Output:

False

NumPy.isposinf() method Example-4:

>>> import numpy as np
>>> np.isposinf([-np.inf, 0., np.inf])

Output:

array([False, False,  True])

NumPy.isposinf() method Example-5:

>>> import numpy as np
>>> x = np.array([-np.inf, 0., np.inf])
>>> y = np.array([4, 4, 4])
>>> np.isposinf(x, y)

Output:

array([0, 0, 1])

NumPy.isposinf() method Example-6:

>>> import numpy as np
>>> x = np.array([-np.inf, 0., np.inf])
>>> y = np.array([4, 4, 4])
>>> np.isposinf(x, y)
>>> y

Output:

array([0, 0, 1])

Python - NumPy Code Editor:

Previous: isneginf() function
Next: iscomplex() function



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/numpy/logic-functions/isposinf.php