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, build_callable=False, **kwargs)[source]#
Bases:
ContainerBase
- _abc_impl = <_abc._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
]], default:None
) – axis or axes along which to perform a logical AND reduction. By default, a 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 validaxis
must be an integer on the interval[-N, N)
, whereN
is the rank(number of dimensions) ofself
. If anaxis
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 invalidaxis
, the function must raise an exception. DefaultNone
.keepdims (
Union
[bool
,Container
], default:False
) – IfTrue
, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see broadcasting). Otherwise, ifFalse
, the reduced axes(dimensions) must not be included in the result. Default:False
.key_chains (
Optional
[Union
[Sequence
[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 – 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
]], default:None
) – axis or axes along which to perform a logical OR reduction. By default, a 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 validaxis
must be an integer on the interval[-N, N)
, whereN
is the rank(number of dimensions) ofself
. If anaxis
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 invalidaxis
, the function must raise an exception. Default:None
.keepdims (
Union
[bool
,Container
], default:False
) – IfTrue
, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see broadcasting). Otherwise, ifFalse
, the reduced axes(dimensions) must not be included in the result. Default:False
.key_chains (
Optional
[Union
[Sequence
[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 array, for writing the result to. It must have a shape that 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
]], default:None
) – axis or axes along which to perform a logical AND reduction. By default, a 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 validaxis
must be an integer on the interval[-N, N)
, whereN
is the rank(number of dimensions) ofself
. If anaxis
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 invalidaxis
, the function must raise an exception. DefaultNone
.keepdims (
Union
[bool
,Container
], default:False
) – IfTrue
, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see broadcasting). Otherwise, ifFalse
, the reduced axes(dimensions) must not be included in the result. Default:False
.key_chains (
Optional
[Union
[Sequence
[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 – 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
]], default:None
) – axis or axes along which to perform a logical OR reduction. By default, a 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 validaxis
must be an integer on the interval[-N, N)
, whereN
is the rank(number of dimensions) ofself
. If anaxis
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 invalidaxis
, the function must raise an exception. Default:None
.keepdims (
Union
[bool
,Container
], default:False
) – IfTrue
, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see broadcasting). Otherwise, ifFalse
, the reduced axes(dimensions) must not be included in the result. Default:False
.key_chains (
Optional
[Union
[Sequence
[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 array, for writing the result to. It must have a shape that 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) }
This should have hopefully given you an overview of the utility submodule, if you have any questions, please feel free to reach out on our discord!