larray.Axis.by

Axis.by(length, step=None)[source]

Split axis into several groups of specified length.

Parameters:

length : int

length of groups

step : int, optional

step between groups. Defaults to length.

Returns:

list of Group

Notes

step can be smaller than length, in which case, this will produce overlapping groups.

Examples

>>> age = Axis(range(10), 'age')
>>> age.by(3)
(age.i[0:3], age.i[3:6], age.i[6:9], age.i[9:10])
>>> age.by(3, 4)
(age.i[0:3], age.i[4:7], age.i[8:10])
>>> age.by(5, 3)
(age.i[0:5], age.i[3:8], age.i[6:10], age.i[9:10])