External

External.norm_shape(shape)[source]

Normalize numpy array shapes so they’re always expressed as a tuple, even for one-dimensional shapes.

Parameters
shape - an int, or a tuple of ints
Returns
a shape tuple
External.sliding_window(a, ws, ss=None, flatten=True)[source]

Return a sliding window over a in any number of dimensions

Parameters:

a - an n-dimensional numpy array ws - an int (a is 1D) or tuple (a is 2D or greater) representing the size

of each dimension of the window
ss - an int (a is 1D) or tuple (a is 2D or greater) representing the
amount to slide the window in each dimension. If not specified, it defaults to ws.
flatten - if True, all slices are flattened, otherwise, there is an
extra dimension for each dimension of the input.
Returns
an array containing each n-dimensional window from a