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)
评论列表
文章目录