Conversions#
Ivy wrapping functions for conversions.
Collection of Ivy functions for wrapping functions to accept and return ivy.Array instances.
- class ivy.data_classes.container.conversions._ContainerWithConversions(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_to_ivy(x, nested=False, include_derived=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, *, out=None)[source]#
ivy.Container static method variant of ivy.to_ivy.
This method simply wraps the function, and so the docstring for ivy.to_ivy also applies to this method with minimal changes.
- Parameters:
x (
Union
[Array
,NativeArray
,Container
]) – The input to be converted.nested (
bool
) – Whether to apply the conversion on arguments in a nested manner. If so, all (default:False
) dicts, lists and tuples will be traversed to their lowest leaves in search of ivy.Array instances. Default isFalse
.include_derived (
Optional
[Dict
[type
,bool
]]) – Whether to also recursive for classes derived from tuple, list and dict. (default:None
) Default isFalse
.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
]]]) – The key-chains to apply or not apply the method to. Default isNone
. (default:None
)to_apply (
bool
) – If True, the method will be applied to key_chains, otherwise key_chains (default:True
) will be skipped. Default isTrue
.prune_unapplied (
bool
) – Whether to prune key_chains for which the function was not applied. (default:False
) Default isFalse
.map_sequences (
bool
) – Whether to also map method to sequences (lists, tuples). (default:False
) Default isFalse
.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 – Container object with all native sub-arrays converted to their ivy.Array instances.
- static _static_to_native(x, nested=False, include_derived=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, *, out=None)[source]#
ivy.Container static method variant of ivy.to_native.
This method simply wraps the function, and so the docstring for ivy.to_native also applies to this method with minimal changes.
- Parameters:
x (
Union
[Array
,NativeArray
,Container
]) – The input to be converted.nested (
bool
) – Whether to apply the conversion on arguments in a nested manner. If so, all (default:False
) dicts, lists and tuples will be traversed to their lowest leaves in search of ivy.Array instances. Default isFalse
.include_derived (
Optional
[Dict
[type
,bool
]]) – Whether to also recursive for classes derived from tuple, list and dict. (default:None
) Default isFalse
.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
]]]) – The key-chains to apply or not apply the method to. Default isNone
. (default:None
)to_apply (
bool
) – If True, the method will be applied to key_chains, otherwise key_chains (default:True
) will be skipped. Default isTrue
.prune_unapplied (
bool
) – Whether to prune key_chains for which the function was not applied. (default:False
) Default isFalse
.map_sequences (
bool
) – Whether to also map method to sequences (lists, tuples). (default:False
) Default isFalse
.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 – Container object with all sub-arrays converted to their native format.
- to_ivy(nested=False, include_derived=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, *, out=None)[source]#
ivy.Container instance method variant of ivy.to_ivy.
This method simply wraps the function, and so the docstring for ivy.to_ivy also applies to this method with minimal changes.
- Parameters:
self (
Container
) – The input to be converted.nested (
bool
) – Whether to apply the conversion on arguments in a nested manner. If so, (default:False
) all dicts, lists and tuples will be traversed to their lowest leaves in search of ivy.Array instances. Default isFalse
.include_derived (
Optional
[Dict
[type
,bool
]]) – Whether to also recursive for classes derived from tuple, list and dict. (default:None
) Default isFalse
.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
]]]) – The key-chains to apply or not apply the method to. Default isNone
. (default:None
)to_apply (
bool
) – If True, the method will be applied to key_chains, otherwise key_chains (default:True
) will be skipped. Default isTrue
.prune_unapplied (
bool
) – Whether to prune key_chains for which the function was not applied. (default:False
) Default isFalse
.map_sequences (
bool
) – Whether to also map method to sequences (lists, tuples). (default:False
) Default isFalse
.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 – Container object with all native sub-arrays converted to their ivy.Array instances.
- to_native(nested=False, include_derived=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, *, out=None)[source]#
ivy.Container instance method variant of ivy.to_native.
This method simply wraps the function, and so the docstring for ivy.to_native also applies to this method with minimal changes.
- Parameters:
self (
Container
) – The input to be converted.nested (
bool
) – Whether to apply the conversion on arguments in a nested manner. If so, all (default:False
) dicts, lists and tuples will be traversed to their lowest leaves in search of ivy.Array instances. Default isFalse
.include_derived (
Optional
[Dict
[type
,bool
]]) – Whether to also recursive for classes derived from tuple, list and dict. (default:None
) Default isFalse
.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
]]]) – The key-chains to apply or not apply the method to. Default isNone
. (default:None
)to_apply (
bool
) – If True, the method will be applied to key_chains, otherwise key_chains (default:True
) will be skipped. Default isTrue
.prune_unapplied (
bool
) – Whether to prune key_chains for which the function was not applied. (default:False
) Default isFalse
.map_sequences (
bool
) – Whether to also map method to sequences (lists, tuples). (default:False
) Default isFalse
.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 – Container object with all sub-arrays converted to their native format.