permutations.py 文件源码

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

项目:brainpipe 作者: EtienneCmb 项目源码 文件源码
def perm_array(x, n_perm=200, rndstate=0):
    """Generate n_perm permutations of a ndarray

    Args:
        x: array
            Data to repeat of shape (d1, d2, ..., d3)

        n_perm: int
            Number of permutations

        rndstate: int
            Fix the random state of the machine

    Returns:
        perm: array
            Repeated data of shape (n_perm, d1, d2, ..., d3)

        idx: array
            Index of permutations of shape (n_perm, d1, d2, ..., d3)
    """
    dim = tuple([n_perm] + list(x.shape))
    xrep = perm_rep(np.ravel(x), n_perm)
    xrep, idx = _scramble2D(xrep, rndstate=rndstate)

    return xrep.reshape(dim), idx.reshape(dim)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号