The array_split Package

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

The two main functions are:

array_split.array_split()
Similar to numpy.array_split(), returns a list of sub-array views of the input numpy.ndarray. Can split along multiple axes and has more splitting criteria (parameters) than numpy.array_split().
array_split.shape_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. Instances of array_split.ShapeSplitter also maintain state related to the computed split.

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

  • Per-axis indices 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.

  • Specification of halo (ghost) elements for sub-arrays.

  • Arbitrary start index for the shape to be partitioned.

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

Attributes

array_split.ARRAY_BOUNDS = <property object>

See array_split.split.ARRAY_BOUNDS

array_split.NO_BOUNDS = <property object>

See array_split.split.NO_BOUNDS