dpnp.array_split

dpnp.array_split(ary, indices_or_sections, axis=0)[source]

Split an array into multiple sub-arrays.

Please refer to the dpnp.split documentation. The only difference between these functions is that dpnp.array_split allows indices_or_sections to be an integer that does not equally divide the axis. For an array of length l that should be split into n sections, it returns l % n sub-arrays of size l//n + 1 and the rest of size l//n.

For full documentation refer to numpy.array_split.

Parameters:
  • ary ({dpnp.ndarray, usm_ndarray}) -- Array to be divided into sub-arrays.

  • indices_or_sections ({int, sequence of ints}) --

    If indices_or_sections is an integer, N, and array length is l, it returns l % n sub-arrays of size l//n + 1 and the rest of size l//n.

    If indices_or_sections is a sequence of sorted integers, the entries indicate where along axis the array is split.

  • axis (int, optional) -- The axis along which to split. Default: 0.

Returns:

sub-arrays -- A list of sub arrays. Each array is a view of the corresponding input array.

Return type:

list of dpnp.ndarray

See also

dpnp.split

Split array into multiple sub-arrays of equal size.

Examples

>>> import dpnp as np
>>> x = np.arange(8.0)
>>> np.array_split(x, 3)
[array([0., 1., 2.]), array([3., 4., 5.]), array([6., 7.])]
>>> x = np.arange(9)
>>> np.array_split(x, 4)
[array([0, 1, 2]), array([3, 4]), array([5, 6]), array([7, 8])]