arrays.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:extract 作者: dblalock 项目源码 文件源码
def sliding_window_1D(x, windowLen):
    """
    Constructs a 2D array whose rows are the data in a sliding window that
    advances one time step at a time.

    Parameters
    ----------
    x : 1D, array-like
        An ordered collection of objects
    windowLen : int > 0
        The legnth of the sliding window

    Returns
    -------
    X : 2D array
        A matrix such that X[i, :] = x[i:i+windowLen]
    """
    x = x.flatten()
    numBytes = x.strides[0]
    numSubseqs = len(x) - windowLen + 1
    return as_strided(x, strides=(numBytes, numBytes), shape=(numSubseqs, windowLen))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号