def windowed_view(X, window_size, window_step=1):
    """Return a windowed view of a 2D array.

    Parameters
    ----------
    X : array-like, shape = (n_samples, n_timestamps)
        Input data.

    window_size : int
        The size of the window. It must be between 1 and ``n_timestamps``.

    window_step : int (default = 1)
        The step of the sliding window

    Returns
    -------
    X_new : array, shape = (n_samples, n_windows, window_size)
        Windowed view of the input data. ``n_windows`` is computed as
        ``(n_timestamps - window_size + window_step) // window_step``.

    Examples
    --------
    >>> import numpy as np
    >>> from pyts.utils import windowed_view
    >>> windowed_view(np.arange(6).reshape(1, -1), window_size=2)
    array([[[0, 1],
            [1, 2],
            [2, 3],
            [3, 4],
            [4, 5]]])

    """
    X = check_array(X, dtype=None)
    n_samples, n_timestamps = X.shape

    if not isinstance(window_size, (int, np.integer)):
        raise TypeError("'window_size' must be an integer.")
    if not 1 <= window_size <= n_timestamps:
        raise ValueError("'window_size' must be an integer between 1 and "
                         "n_timestamps.")
    if not isinstance(window_step, (int, np.integer)):
        raise TypeError("'window_step' must be an integer.")
    if not 1 <= window_step <= n_timestamps:
        raise ValueError("'window_step' must be an integer between 1 and "
                         "n_timestamps.")

    return _windowed_view(X, n_samples, n_timestamps, window_size, window_step)
Return a windowed view of a 2D array.

    Parameters
    ----------
    X : array-like, shape = (n_samples, n_timestamps)
        Input data.

    window_size : int
        The size of the window. It must be between 1 and ``n_timestamps``.

    window_step : int (default = 1)
        The step of the sliding window

    Returns
    -------
    X_new : array, shape = (n_samples, n_windows, window_size)
        Windowed view of the input data. ``n_windows`` is computed as
        ``(n_timestamps - window_size + window_step) // window_step``.

    Examples
    --------
    >>> import numpy as np
    >>> from pyts.utils import windowed_view
    >>> windowed_view(np.arange(6).reshape(1, -1), window_size=2)
    array([[[0, 1],
            [1, 2],
            [2, 3],
            [3, 4],
            [4, 5]]])

    
pyts/utils/utils.py