isinf#
- ivy.isinf(x, /, *, detect_positive=True, detect_negative=True, out=None)[source]#
Test each element x_i of the input array x to determine if equal to positive or negative infinity.
- Parameters:
x (
Union
[Array
,NativeArray
]) – input array. Should have a numeric data type.detect_positive (
bool
) – ifTrue
, positive infinity is detected. (default:True
)detect_negative (
bool
) – ifTrue
, negative infinity is detected. (default:True
)out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a shape that the (default:None
) inputs broadcast to.
- Return type:
- Returns:
ret – an array containing test results. An element out_i is True if x_i is either positive or negative infinity and False otherwise. The returned array must have a data type of bool.
This function conforms to the Array API Standard. This docstring is an extension of the docstring # noqa in the standard.
Both the description and the type hints above assumes an array input for simplicity, but this function is nestable, and therefore also accepts
ivy.Container
instances in place of any of the arguments.Examples
With
ivy.Array
inputs:>>> x = ivy.array([1, 2, 3]) >>> z = ivy.isinf(x) >>> print(z) ivy.array([False, False, False])
>>> x = ivy.array([[1.1, 2.3, -3.6]]) >>> z = ivy.isinf(x) >>> print(z) ivy.array([[False, False, False]])
>>> x = ivy.array([[[1.1], [float('inf')], [-6.3]]]) >>> z = ivy.isinf(x) >>> print(z) ivy.array([[[False], [True], [False]]])
>>> x = ivy.array([[-float('inf'), float('inf'), 0.0]]) >>> z = ivy.isinf(x) >>> print(z) ivy.array([[ True, True, False]])
>>> x = ivy.zeros((3, 3)) >>> z = ivy.isinf(x) >>> print(z) ivy.array([[False, False, False], [False, False, False], [False, False, False]])
With
ivy.Container
input:>>> x = ivy.Container(a=ivy.array([-1, -float('inf'), 1.23]), ... b=ivy.array([float('inf'), 3.3, -4.2])) >>> z = ivy.isinf(x) >>> print(z) { a: ivy.array([False, True, False]), b: ivy.array([True, False, False]) }
With
ivy.Container
input:>>> x = ivy.Container(a=ivy.array([-1, -float('inf'), 1.23]), ... b=ivy.array([float('inf'), 3.3, -4.2])) >>> x.isinf() { a: ivy.array([False, True, False]), b: ivy.array([True, False, False]) }
- Array.isinf(self, *, detect_positive=True, detect_negative=True, out=None)#
ivy.Array instance method variant of ivy.isinf. This method simply wraps the function, and so the docstring for ivy.isinf also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array. Should have a real-valued data type.detect_positive (
bool
) – ifTrue
, positive infinity is detected. (default:True
)detect_negative (
bool
) – ifTrue
, negative infinity is detected. (default:True
)out (
Optional
[Array
]) – optional output array, for writing the result to. It must have a shape that (default:None
) the inputs broadcast to.
- Return type:
Array
- Returns:
ret – an array containing test results. An element
out_i
isTrue
ifself_i
is either positive or negative infinity andFalse
otherwise. The returned array must have a data type ofbool
.
Examples
With
ivy.Array
inputs:>>> x = ivy.array([1, 2, 3]) >>> x.isinf() ivy.array([False, False, False])
>>> x = ivy.array([[1.1, 2.3, -3.6]]) >>> x.isinf() ivy.array([[False, False, False]])
>>> x = ivy.array([[[1.1], [float('inf')], [-6.3]]]) >>> x.isinf() ivy.array([[[False],[True],[False]]])
>>> x = ivy.array([[-float('inf'), float('inf'), 0.0]]) >>> x.isinf() ivy.array([[ True, True, False]])
>>> x = ivy.zeros((3, 3)) >>> x.isinf() ivy.array([[False, False, False], [False, False, False], [False, False, False]])
- Container.isinf(self, *, detect_positive=True, detect_negative=True, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)#
ivy.Container instance method variant of ivy.isinf. This method simply wraps the function, and so the docstring for ivy.isinf also applies to this method with minimal changes.
- Parameters:
self (
Container
) – input container. Should have a real-valued data type.detect_positive (
bool
) – ifTrue
, positive infinity is detected. (default:True
)detect_negative (
bool
) – ifTrue
, negative infinity is detected. (default:True
)key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
]]]) – The key-chains to apply or not apply the method to. Default isNone
. (default:None
)to_apply (
bool
) – If True, the method will be applied to key_chains, otherwise key_chains (default:True
) will be skipped. Default isTrue
.prune_unapplied (
bool
) – Whether to prune key_chains for which the function was not applied. (default:False
) Default isFalse
.map_sequences (
bool
) – Whether to also map method to sequences (lists, tuples). (default:False
) Default isFalse
.out (
Optional
[Container
]) – optional output container, for writing the result to. It must have a shape (default:None
) that the inputs broadcast to.
- Return type:
Container
- Returns:
ret – a container containing the test result. An element
out_i
isTrue
ifself_i
is either positive or negative infinity andFalse
otherwise. The returned array must have a data type ofbool
.
Examples
With
ivy.Container
input:>>> x = ivy.Container(a=ivy.array([-1, -float('inf'), 1.23]), ... b=ivy.array([float('inf'), 3.3, -4.2])) >>> z = x.isinf() >>> print(z) { a: ivy.array([False, True, False]), b: ivy.array([True, False, False]) }