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.

  • 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 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)[source]#

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.

  • 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.

  • 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)[source]#

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.

  • copy (Optional[Union[bool, Container]], 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 and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

  • 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 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.]])
}]