def ind2sub(shape, inds):
"""From the given shape, returns the subscripts of the given index"""
if type(inds) is not np.ndarray:
inds = np.array(inds)
assert len(inds.shape) == 1, (
'Indexing must be done as a 1D row vector, e.g. [3,6,6,...]'
)
return np.unravel_index(inds, shape, order='F')
评论列表
文章目录