hsplit#
- ivy.hsplit(ary, indices_or_sections, /, *, copy=None)[source]#
Split an array into multiple sub-arrays horizontally.
- Parameters:
ary (
Union
[Array
,NativeArray
]) – Array input.indices_or_sections (
Union
[int
,Sequence
[int
],Array
,NativeArray
]) – If indices_or_sections is an integer n, the array is split into n equal sections, provided that n must be a divisor of the split axis. If indices_or_sections is a tuple of ints, then input is split at each of the indices in the tuple.copy (
Optional
[bool
], default:None
) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy. In case copy is False we avoid copying by returning a view of the input array.
- Return type:
List
[Array
]- Returns:
ret – input array split horizontally.
Examples
>>> ary = ivy.array( [[0., 1., 2., 3.], [4., 5., 6, 7.], [8., 9., 10., 11.], [12., 13., 14., 15.]] ) >>> ivy.hsplit(ary, 2) [ivy.array([[ 0., 1.], [ 4., 5.], [ 8., 9.], [12., 13.]]), ivy.array([[ 2., 3.], [ 6., 7.], [10., 11.], [14., 15.]])]
- Array.hsplit(self, indices_or_sections, /, *, copy=None)[source]#
ivy.Array instance method variant of ivy.hsplit. This method simply wraps the function, and so the docstring for ivy.hsplit also applies to this method with minimal changes.
- Parameters:
self (
Array
) – Input array.indices_or_sections (
Union
[int
,Tuple
[int
,...
]]) – If indices_or_sections is an integer n, the array is split into n equal sections, provided that n must be a divisor of the split axis. If indices_or_sections is a sequence of ints or 1-D array, then input is split at each of the indices.copy (
Optional
[bool
], default:None
) –boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy. In case copy is False we avoid copying by returning
a view of the input array.
- Return type:
List
[Array
]- Returns:
ret – list of arrays split horizontally from input array.
Examples
>>> ary = ivy.array( [[0., 1., 2., 3.], [4., 5., 6, 7.], [8., 9., 10., 11.], [12., 13., 14., 15.]] ) >>> ary.hsplit(2) [ivy.array([[ 0., 1.], [ 4., 5.], [ 8., 9.], [12., 13.]]), ivy.array([[ 2., 3.], [ 6., 7.], [10., 11.], [14., 15.]]))
- Container.hsplit(self, indices_or_sections, copy=None, /)[source]#
ivy.Container instance method variant of ivy.hsplit. This method simply wraps the function, and so the docstring for ivy.hsplit also applies to this method with minimal changes.
- Parameters:
self (
Container
) – the container with array inputs.indices_or_sections (
Union
[int
,Sequence
[int
],Array
,NativeArray
,Container
]) – If indices_or_sections is an integer n, the array is split into n equal sections, provided that n must be a divisor of the split axis. If indices_or_sections is a sequence of ints or 1-D array, then input is split at each of the indices.
- Return type:
List
[Container
]- Returns:
ret – list of containers split horizontally from input container
Examples
>>> ary = ivy.Container( a = ivy.array( [[[0., 1.], [2., 3.]], [[4., 5.], [6., 7.]]] ), b=ivy.array( [0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15.] ) ) >>> ary.hsplit(2) [{ a: ivy.array([[[0., 1.]], [[4., 5.]]]), b: ivy.array([0., 1., 2., 3., 4., 5., 6., 7.]) }, { a: ivy.array([[[2., 3.]], [[6., 7.]]]), b: ivy.array([8., 9., 10., 11., 12., 13., 14., 15.]) }]