logical_or#
- ivy.logical_or(x1, x2, /, *, out=None)[source]#
Compute the logical OR for each element
x1_i
of the input arrayx1
with the respective elementx2_i
of the input arrayx2
.Note
While this specification recommends that this function only accept input arrays having a boolean data type, specification-compliant array libraries may choose to accept input arrays having numeric data types. If non-boolean data types are supported, zeros must be considered the equivalent of
False
, while non-zeros must be considered the equivalent ofTrue
.- Parameters:
x1 (
Union
[Array
,NativeArray
]) – first input array. Should have a boolean data type.x2 (
Union
[Array
,NativeArray
]) – second input array. Must be compatible withx1
(see broadcasting). Should have a boolean 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:
- Returns:
ret – an array containing the element-wise results. 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 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
input:>>> x = ivy.array([True, False, True]) >>> y = ivy.array([True, True, False]) >>> print(ivy.logical_or(x, y)) ivy.array([ True, True, True])
>>> x = ivy.array([[False, False, True], [True, False, True]]) >>> y = ivy.array([[False, True, False], [True, True, False]]) >>> z = ivy.zeros_like(x) >>> ivy.logical_or(x, y, out=z) >>> print(z) ivy.array([[False, True, True], [ True, True, True]])
>>> x = ivy.array([False, 3, 0]) >>> y = ivy.array([2, True, False]) >>> ivy.logical_or(x, y, out=x) >>> print(x) ivy.array([1, 1, 0])
With
ivy.Container
input:>>> x = ivy.Container(a=ivy.array([False, False, True]), ... b=ivy.array([True, False, True])) >>> y = ivy.Container(a=ivy.array([False, True, False]), ... b=ivy.array([True, True, False])) >>> z = ivy.logical_or(x, y) >>> print(z) { a: ivy.array([False, True, True]), b: ivy.array([True, True, True]) }
- Array.logical_or(self, x2, /, *, out=None)[source]#
ivy.Array instance method variant of ivy.logical_or. This method simply wraps the function, and so the docstring for ivy.logical_or also applies to this method with minimal changes.
- Parameters:
self (
Array
) – first input array. Should have a boolean data type.x2 (
Union
[Array
,NativeArray
]) – second input array. Must be compatible withself
(see broadcasting). Should have a boolean 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 the element-wise results. The returned array must have a data type of
bool
.This function conforms to the `Array API Standard
<https (//data-apis.org/array-api/latest/>`_. This docstring is an extension of)
the `docstring <https (//data-apis.org/array-api/latest/)
API_specification/generated/array_api.logical_or.html>`_
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
Using
ivy.Array
instance method:>>> x = ivy.array([False, 3, 0]) >>> y = ivy.array([2, True, False]) >>> z = x.logical_or(y) >>> print(z) ivy.array([ True, True, False])
- Container.logical_or(self, x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
ivy.Container instance method variant of ivy.logical_or. This method simply wraps the function, and so the docstring for ivy.logical_or also applies to this method with minimal changes.
- Parameters:
self (
Container
) – input array or container. Should have a boolean data type.x2 (
Union
[Container
,Array
,NativeArray
]) – input array or container. Must be compatible withself
(see broadcasting). Should have a boolean 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 element-wise results. The returned container must have a data type of
bool
.This function conforms to the `Array API Standard
<https (//data-apis.org/array-api/latest/>`_. This docstring is an extension of)
the `docstring <https (//data-apis.org/array-api/latest/)
API_specification/generated/array_api.logical_or.html>`_
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
Using
ivy.Container
instance method:>>> x = ivy.Container(a=ivy.array([False,True,True]), ... b=ivy.array([3.14, 2.718, 1.618])) >>> y = ivy.Container(a=ivy.array([0, 5.2, 0.8]), b=ivy.array([0.2, 0, 0.9])) >>> z = x.logical_or(y) >>> print(z) { a: ivy.array([False, True, True]), b: ivy.array([True, True, True]) }