INNER CODE UNIT · Python
rolling_window
matrix-profile-foundation/matrixprofile · matrixprofile/core.py:261
def rolling_window(a, window):
"""
Provides a rolling window on a numpy array given an array and window size.
Parameters
----------
a : array_like
The array to create a rolling window on.
window : int
The window size.
Returns
-------
Strided array for computation.
"""
shape = a.shape[:-1] + (a.shape[-1] - window + 1, window)
strides = a.strides + (a.strides[-1],)