Utility#

class ivy.data_classes.container.utility._ContainerWithUtility(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, **kwargs)[source]#

Bases: ContainerBase

_abc_impl = <_abc_data object>#
static _static_all(x, /, *, axis=None, keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – input container.

  • axis (Optional[Union[int, Sequence[int], Container]]) – axis or axes along which to perform a logical AND reduction. By default, a (default: None) logical AND reduction must be performed over the entire array. If a tuple of integers, logical AND reductions must be performed over multiple axes. A valid axis must be an integer on the interval [-N, N), where N is the rank(number of dimensions) of self. If an axis is specified as a negative integer, the function must determine the axis along which to perform a reduction by counting backward from the last dimension (where -1 refers to the last dimension). If provided an invalid axis, the function must raise an exception. Default None.

  • keepdims (Union[bool, Container]) – If True, the reduced axes (dimensions) must be included in the result as (default: False) singleton dimensions, and, accordingly, the result must be compatible with the input array (see broadcasting). Otherwise, if False, the reduced axes(dimensions) must not be included in the result. Default: False.

  • key_chains (Optional[Union[Sequence[str], Dict[str, str]]]) – The key-chains to apply or not apply the method to. Default is None. (default: None)

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

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

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

  • 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 – if a logical AND reduction was performed over the entire array, the returned container must be a zero-dimensional array containing the test result; otherwise, the returned container must be a non-zero-dimensional array containing the test results. The returned container must have a data type of bool.

Examples

>>> x = ivy.Container(a=ivy.array([0, 1, 2]), b=ivy.array([0, 1, 1]))
>>> y = ivy.Container.static_all(x)
>>> print(y)
{
    a: ivy.array(False),
    b: ivy.array(False)
}
static _static_any(x, /, *, axis=None, keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – input container.

  • axis (Optional[Union[int, Sequence[int], Container]]) – axis or axes along which to perform a logical OR reduction. By default, a (default: None) logical OR reduction must be performed over the entire array. If a tuple of integers, logical OR reductions must be performed over multiple axes. A valid axis must be an integer on the interval [-N, N), where N is the rank(number of dimensions) of self. If an axis is specified as a negative integer, the function must determine the axis along which to perform a reduction by counting backward from the last dimension (where -1 refers to the last dimension). If provided an invalid axis, the function must raise an exception. Default: None.

  • keepdims (Union[bool, Container]) – If True, the reduced axes (dimensions) must be included in the result as (default: False) singleton dimensions, and, accordingly, the result must be compatible with the input array (see broadcasting). Otherwise, if False, the reduced axes(dimensions) must not be included in the result. Default: False.

  • key_chains (Optional[Union[Sequence[str], Dict[str, str]]]) – The key-chains to apply or not apply the method to. Default is None. (default: None)

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

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

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

  • out (Optional[Container]) – optional output array, for writing the result to. It must have a shape that (default: None) the inputs broadcast to.

Return type:

Container

Returns:

ret – if a logical OR reduction was performed over the entire array, the returned container must be a zero-dimensional array containing the test result; otherwise, the returned container must have non-zero-dimensional arrays containing the test results. The returned container must have a data type of bool.

Examples

>>> x = ivy.Container(a=ivy.array([0, 1, 2]), b=ivy.array([0, 0, 0]))
>>> y = ivy.Container.static_any(x)
>>> print(y)
{
    a: ivy.array(True),
    b: ivy.array(False)
}
all(*, axis=None, keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input container.

  • axis (Optional[Union[int, Sequence[int], Container]]) – axis or axes along which to perform a logical AND reduction. By default, a (default: None) logical AND reduction must be performed over the entire array. If a tuple of integers, logical AND reductions must be performed over multiple axes. A valid axis must be an integer on the interval [-N, N), where N is the rank(number of dimensions) of self. If an axis is specified as a negative integer, the function must determine the axis along which to perform a reduction by counting backward from the last dimension (where -1 refers to the last dimension). If provided an invalid axis, the function must raise an exception. Default None.

  • keepdims (Union[bool, Container]) – If True, the reduced axes (dimensions) must be included in the result as (default: False) singleton dimensions, and, accordingly, the result must be compatible with the input array (see broadcasting). Otherwise, if False, the reduced axes(dimensions) must not be included in the result. Default: False.

  • key_chains (Optional[Union[Sequence[str], Dict[str, str]]]) – The key-chains to apply or not apply the method to. Default is None. (default: None)

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

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

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

  • 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 – if a logical AND reduction was performed over the entire array, the returned container must be a zero-dimensional array containing the test result; otherwise, the returned container must have non-zero-dimensional arrays containing the test results. The returned container must have a data type of bool.

Examples

>>> x = ivy.Container(a=ivy.array([0, 1, 2]), b=ivy.array([0, 1, 1]))
>>> y = x.all()
>>> print(y)
{
    a: ivy.array(False),
    b: ivy.array(False)
}
any(*, axis=None, keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input container.

  • axis (Optional[Union[int, Sequence[int], Container]]) – axis or axes along which to perform a logical OR reduction. By default, a (default: None) logical OR reduction must be performed over the entire array. If a tuple of integers, logical OR reductions must be performed over multiple axes. A valid axis must be an integer on the interval [-N, N), where N is the rank(number of dimensions) of self. If an axis is specified as a negative integer, the function must determine the axis along which to perform a reduction by counting backward from the last dimension (where -1 refers to the last dimension). If provided an invalid axis, the function must raise an exception. Default: None.

  • keepdims (Union[bool, Container]) – If True, the reduced axes (dimensions) must be included in the result as (default: False) singleton dimensions, and, accordingly, the result must be compatible with the input array (see broadcasting). Otherwise, if False, the reduced axes(dimensions) must not be included in the result. Default: False.

  • key_chains (Optional[Union[Sequence[str], Dict[str, str]]]) – The key-chains to apply or not apply the method to. Default is None. (default: None)

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

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

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

  • out (Optional[Container]) – optional output array, for writing the result to. It must have a shape that (default: None) the inputs broadcast to.

Return type:

Container

Returns:

ret – if a logical OR reduction was performed over the entire array, the returned container must be a zero-dimensional array containing the test result; otherwise, the returned container must have non-zero-dimensional arrays containing the test results. The returned container must have a data type of bool.

Examples

>>> x = ivy.Container(a=ivy.array([0, 1, 2]), b=ivy.array([0, 0, 0]))
>>> y = x.any()
>>> print(y)
{
    a: ivy.array(True),
    b: ivy.array(False)
}