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, build_callable=False, **kwargs)[source]#
Bases:
ContainerBase
- _abc_impl = <_abc._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 (
Union
[bool
,Container
], default:False
) – Whether to apply the conversion on arguments in a nested manner. If so, all dicts, lists and tuples will be traversed to their lowest leaves in search of ivy.Array instances. Default isFalse
.include_derived (
Optional
[Union
[Dict
[str
,bool
],Container
]], default:None
) – Whether to also recursive for classes derived from tuple, list and dict. Default isFalse
.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 – 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 (
Union
[bool
,Container
], default:False
) – Whether to apply the conversion on arguments in a nested manner. If so, all dicts, lists and tuples will be traversed to their lowest leaves in search of ivy.Array instances. Default isFalse
.include_derived (
Optional
[Union
[Dict
[str
,bool
],Container
]], default:None
) – Whether to also recursive for classes derived from tuple, list and dict. Default isFalse
.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 – 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 (
Union
[bool
,Container
], default:False
) – Whether to apply the conversion on arguments in a nested manner. If so, all dicts, lists and tuples will be traversed to their lowest leaves in search of ivy.Array instances. Default isFalse
.include_derived (
Optional
[Union
[Dict
[str
,bool
],Container
]], default:None
) – Whether to also recursive for classes derived from tuple, list and dict. Default isFalse
.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 – 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 (
Union
[bool
,Container
], default:False
) – Whether to apply the conversion on arguments in a nested manner. If so, all dicts, lists and tuples will be traversed to their lowest leaves in search of ivy.Array instances. Default isFalse
.include_derived (
Optional
[Union
[Dict
[str
,bool
],Container
]], default:None
) – Whether to also recursive for classes derived from tuple, list and dict. Default isFalse
.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 – Container object with all sub-arrays converted to their native format.