less_equal#

ivy.less_equal(x1, x2, /, *, out=None)[source]#

Compute the truth value of x1_i <= x2_i for each element x1_i of the input array x1 with the respective element x2_i of the input array x2.

Parameters:
  • x1 (Union[Array, NativeArray]) – first input array. May have any data type.

  • x2 (Union[Array, NativeArray]) – second input array. Must be compatible with x1 (with Broadcasting). May have any 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. 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.less_equal(ivy.array([1,2,3]),ivy.array([2,2,2]))
>>> print(x)
ivy.array([True, True,  False])
>>> x = ivy.array([[10.1, 2.3, -3.6]])
>>> y = ivy.array([[4.8], [5.2], [6.1]])
>>> shape = (3,3)
>>> fill_value = False
>>> z = ivy.full(shape, fill_value)
>>> ivy.less_equal(x, y, out=z)
>>> print(z)
ivy.array([[False,  True,  True],
       [False,  True,  True],
       [False,  True,  True]])
>>> x = ivy.array([[[1.1], [3.2], [-6.3]]])
>>> y = ivy.array([[8.4], [2.5], [1.6]])
>>> ivy.less_equal(x, y, out=x)
>>> print(x)
ivy.array([[[1.],
        [0.],
        [1.]]])

With ivy.Container input:

>>> x = ivy.Container(a=ivy.array([4, 5, 6]),b=ivy.array([2, 3, 4]))
>>> y = ivy.Container(a=ivy.array([1, 2, 3]),b=ivy.array([5, 6, 7]))
>>> z = ivy.less_equal(x, y)
>>> print(z)
{
    a: ivy.array([False, False, False]),
    b: ivy.array([True, True, True])
}
Array.less_equal(self, x2, /, *, out=None)[source]#

ivy.Array instance method variant of ivy.less_equal. This method simply wraps the function, and so the docstring for ivy.less_equal also applies to this method with minimal changes.

Parameters:
  • self (Array) – first input array. Should have a real-valued data type.

  • x2 (Union[Array, NativeArray]) – second input array. Must be compatible with self (see broadcasting). 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 the element-wise results. The returned array must have a data type of bool.

Examples

With :code:’ivy.Array’ inputs:

>>> x1 = ivy.array([1, 2, 3])
>>> x2 = ivy.array([2, 2, 1])
>>> y = x1.less_equal(x2)
>>> print(y)
ivy.array([True, True, False])

With mixed :code:’ivy.Array’ and :code:’ivy.NativeArray’ inputs:

>>> x1 = ivy.array([2.5, 3.3, 9.24])
>>> x2 = ivy.native_array([2.5, 1.1, 9.24])
>>> y = x1.less_equal(x2)
>>> print(y)
ivy.array([True, False, True])

With mixed :code:’ivy.Container’ and :code:’ivy.Array’ inputs:

>>> x1 = ivy.array([3., 1., 0.8])
>>> x2 = ivy.Container(a=ivy.array([2., 1., 0.7]), b=ivy.array([3., 0.6, 1.2]))
>>> y = x1.less_equal(x2)
>>> print(y)
{
    a: ivy.array([False, True, False]),
    b: ivy.array([True, False, True])
}
Container.less_equal(self, x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.less_equal. This method simply wraps the function, and so the docstring for ivy.less_equal also applies to this method with minimal changes.

Parameters:
  • self (Container) – input array or container. Should have a real-valued data type.

  • x2 (Union[Container, Array, NativeArray]) – input array or container. Must be compatible with self (see broadcasting). 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 is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • 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.

Examples

With :code:’ivy.Container’ inputs:

>>> x1 = ivy.Container(a=ivy.array([12, 3.5, 9.2]), b=ivy.array([2., 1.1, 5.5]))
>>> x2 = ivy.Container(a=ivy.array([12, 2.2, 4.1]), b=ivy.array([1, 0.7, 3.8]))
>>> y = x1.less_equal(x2)
>>> print(y)
{
    a: ivy.array([True, False, False]),
    b: ivy.array([False, False, False])
}

With mixed :code:’ivy.Container’ and :code:’ivy.Array’ inputs:

>>> x1 = ivy.Container(a=ivy.array([12., 3.5, 9.2]), b=ivy.array([2., 1., 5.5]))
>>> x2 = ivy.array([2., 1.1, 5.5])
>>> y = x1.less_equal(x2)
>>> print(y)
{
    a: ivy.array([False, False, False]),
    b: ivy.array([True, True, True])
}