dsplit#

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

Split an array into multiple sub-arrays along the 3rd axis.

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 sections. If the array is divisible by n along the 3rd axis, each section will be of equal size. If input is not divisible by n, the sizes of the first int(ary.size(0) % n) sections will have size int(ary.size(0) / n) + 1, and the rest will have size int(ary.size(0) / n). 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 along the 3rd axis.

Examples

>>> ary = ivy.array(
    [[[ 0.,   1.,   2.,   3.],
      [ 4.,   5.,   6.,   7.]],
     [[ 8.,   9.,  10.,  11.],
      [12.,  13.,  14.,  15.]]]
    )
>>> ivy.dsplit(ary, 2)
[ivy.array([[[ 0.,  1.], [ 4.,  5.]], [[ 8.,  9.], [12., 13.]]]),
 ivy.array([[[ 2.,  3.], [ 6.,  7.]], [[10., 11.], [14., 15.]]])]
Array.dsplit(self, indices_or_sections, /, *, copy=None)[source]#

ivy.Array instance method variant of ivy.dsplit. This method simply wraps the function, and so the docstring for ivy.dsplit 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.

  • 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 along the 3rd axis.

Examples

>>> ary = ivy.array(
    [[[ 0.,   1.,   2.,   3.],
      [ 4.,   5.,   6.,   7.]],
     [[ 8.,   9.,  10.,  11.],
      [12.,  13.,  14.,  15.]]]
)
>>> ary.dsplit(2)
[ivy.array([[[ 0.,  1.], [ 4.,  5.]], [[ 8.,  9.], [12., 13.]]]),
ivy.array([[[ 2.,  3.], [ 6.,  7.]], [[10., 11.], [14., 15.]]])]
Container.dsplit(self, indices_or_sections, /, *, copy=None)[source]#

ivy.Container instance method variant of ivy.dsplit. This method simply wraps the function, and so the docstring for ivy.dsplit 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.

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

Return type:

List[Container]

Returns:

ret – list of containers holding arrays split from the input at the 3rd axis

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