isreal#
- ivy.isreal(x, /, *, out=None)[source]#
Test each element
x_i
of the input arrayx
to determine whether the element is real number. Returns a bool array, where True if input element is real. If element has complex type with zero complex part, the return value for that element is True.- Parameters:
- Return type:
- Returns:
ret – an array containing test results. An element
out_i
isTrue
ifx_i
is real number andFalse
otherwise. The returned array should have a data type ofbool
.The descriptions above assume an array input for simplicity, but
the method also accepts
ivy.Container
instances in place ofivy.Array
orivy.NativeArray
instances, as shown in the type hintsand also the examples below.
Examples
With
ivy.Array
inputs:>>> x = ivy.array([[[1.1], [float('inf')], [-6.3]]]) >>> z = ivy.isreal(x) >>> print(z) ivy.array([[[True], [True], [True]]])
>>> x = ivy.array([1-0j, 3j, 7+5j]) >>> z = ivy.isreal(x) >>> print(z) ivy.array([ True, False, False])
With
ivy.Container
input:>>> x = ivy.Container(a=ivy.array([-6.7-7j, -np.inf, 1.23]), b=ivy.array([5j, 5-6j, 3])) >>> z = ivy.isreal(x) >>> print(z) { a: ivy.array([False, True, True]), b: ivy.array([False, False, True]) }
- Array.isreal(self, *, out=None)[source]#
ivy.Array instance method variant of ivy.isreal. This method simply wraps the function, and so the docstring for ivy.isreal also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array. Should have a real-valued data type.out (
Optional
[Array
], default:None
) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – an array containing test results. An element
out_i
isTrue
ifself_i
is real number andFalse
otherwise. The returned array should have a data type ofbool
.
Examples
>>> x = ivy.array([1j, 2+5j, 3.7-6j]) >>> x.isreal() ivy.array([False, False, False])
- Container.isreal(self, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
ivy.Container instance method variant of ivy.isreal. This method simply wraps the function, and so the docstring for ivy.isreal also applies to this method with minimal changes.
- Parameters:
self (
Container
) – input container. Should have a real-valued data type.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
],Container
]], default:None
) – The key-chains to apply or not apply the method to. Default isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.out (
Optional
[Container
], default:None
) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.
- Return type:
Container
- Returns:
ret – a container containing the test result. An element
out_i
isTrue
ifself_i
is real number andFalse
otherwise. The returned array should have a data type ofbool
.
Examples
>>> x = ivy.Container(a=ivy.array([-1j, -np.inf, 1.23+7j]), b=ivy.array([0.0, 3.3j, 1+0j])) >>> y = x.isreal() >>> print(y) { a: ivy.array([False, True, False]), b: ivy.array([True, False, True]) }