NumPy Logic functions: isneginf() function
numpy.isneginf() function
The isneginf() function is used to test element-wise for negative infinity, return result as bool array.
Syntax:
numpy.isneginf(x, out=None)
Version: 1.15.0
Parameter:
Name | Description | Required / Optional |
---|---|---|
x | The input array. array_like |
Required |
out | A boolean array with the same shape and type 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 numpy boolean array is returned with values
True where the corresponding element of the input is negative infinity and values False where the element of the input is not negative 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.isneginf() method Example-1:
>>> import numpy as np
>>> np.isneginf(np.NINF)
Output:
True
NumPy.isneginf() method Example-2:
>>> import numpy as np
>>> np.isneginf(np.inf)
Output:
False
NumPy.isneginf() method Example-3:
>>> import numpy as np
>>> np.isneginf(np.PINF)
Output:
False
NumPy.isneginf() method Example-4:
>>> import numpy as np
>>> np.isneginf([-np.inf, 0., np.inf])
Output:
array([ True, False, False])
NumPy.isneginf() method Example-5:
>>> import numpy as np
>>> x = np.array([-np.inf, 0., np.inf])
>>> y = np.array([3, 3, 3])
>>> np.isneginf(x, y)
Output:
array([1, 0, 0])
NumPy.isneginf() method Example-6:
>>> import numpy as np
>>> x = np.array([-np.inf, 0., np.inf])
>>> y = np.array([3, 3, 3])
>>> np.isneginf(x, y)
>>> y
Output:
array([1, 0, 0])
Python - NumPy Code Editor:
Previous: isnat() function
Next: isposinf() function
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://www.w3resource.com/numpy/logic-functions/isneginf.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics