vsplit#

ivy.vsplit(ary, indices_or_sections, /, *, copy=None)[source]#

Split an array vertically into multiple sub-arrays.

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 sequence of ints or 1-D array, then input is split at each of the indices.

Return type:

List[Array]

Returns:

ret – input array split vertically.

Examples

>>> ary = ivy.array(
    [[[0.,  1.],
      [2.,  3.]],
     [[4.,  5.],
      [6.,  7.]]]
    )
>>> ivy.vsplit(ary, 2)
[ivy.array([[[0., 1.], [2., 3.]]]), ivy.array([[[4., 5.], [6., 7.]]])])
Array.vsplit(self, indices_or_sections, /, *, copy=None)#

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

Parameters:
  • self (Array) – Input array.

  • indices_or_sections (Union[int, Sequence[int], Array]) – 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[Array]

Returns:

ret – input array split vertically.

Examples

>>> ary = ivy.array(
    [[[0.,  1.],
      [2.,  3.]],
     [[4.,  5.],
      [6.,  7.]]]
    )
>>> ary.vsplit(2)
[ivy.array([[[0., 1.], [2., 3.]]]), ivy.array([[[4., 5.], [6., 7.]]])])
Container.vsplit(self, indices_or_sections, /, *, copy=None)#

ivy.Container instance method variant of ivy.vsplit. This method simply wraps the function, and so the docstring for ivy.vsplit 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]) – 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 holding arrays split vertically from the input

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.vsplit(2)
[{
    a: ivy.array([[[0., 1.],
                   [2., 3.]]]),
    b: ivy.array([[0., 1., 2., 3.],
                  [4., 5., 6., 7.]])
}, {
    a: ivy.array([[[4., 5.],
                   [6., 7.]]]),
    b: ivy.array([[8., 9., 10., 11.],
                  [12., 13., 14., 15.]])
}]