flopscope.numpy.array_split
fnp.array_split(ary, indices_or_sections, axis=0)[flopscope source][numpy source]
Split an array into multiple sub-arrays.
Adapted from NumPy docs np.array_split
Cost
0
Flopscope Context
Split array into sub-arrays (possibly unequal). Cost: numel(output).
Please refer to the split documentation. The only difference
between these functions is that 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.
See also
- we.flops.split Split array into multiple sub-arrays of equal size.
Examples
>>> import flopscope.numpy as fnp
>>> x = flops.arange(8.0)
>>> flops.array_split(x, 3)
[array([0., 1., 2.]), array([3., 4., 5.]), array([6., 7.])]>>> x = flops.arange(9)
>>> flops.array_split(x, 4)
[array([0, 1, 2]), array([3, 4]), array([5, 6]), array([7, 8])]