The array_split Package

Small python package for splitting a numpy.ndarray (or just an array shape) into a number of sub-arrays.

The two main functions are:

Similar to numpy.array_split(), returns a list of views of sub-arrays of the input numpy.ndarray. Can split along multiple axes and has more splitting criteria (parameters) than numpy.array_split().
Instead taking an numpy.ndarray as an argument, it takes the array shape and returns tuples of slice objects which indicate the extents of the sub-arrays.

These two functions use an instance of the array_split.ShapeSplitter class which contains the bulk of the split implementation and maintains some state related to the computed split.

Splitting of multi-dimensional arrays can be performed according to several criteria:

  • Per-axis indicies indicating the cut positions.

  • Per-axis number of sub-arrays.

  • Total number of sub-arrays (with optional per-axis number of sections constraints).

  • Specific sub-array shape.

  • Maximum number of bytes for a sub-array with constraints:

    • sub-arrays are an even multiple of a specified sub-tile shape
    • upper limit on the per-axis sub-array shape

The usage documentation is given in the Examples section.

Classes and Functions

shape_split(array_shape, *args, **kwargs) Splits specified array_shape in tiles, returns array of slice tuples.
array_split(ary[, indices_or_sections, ...]) Splits the specified array ary into sub-arrays, returns list of numpy.ndarray.
ShapeSplitter(array_shape[, ...]) Implements array shape splitting.


array_split.ARRAY_BOUNDS = <property object>

See array_split.split.ARRAY_BOUNDS

array_split.NO_BOUNDS = <property object>

See array_split.split.NO_BOUNDS