TestFromFixedCountsToRhoOmegaBetter.py 文件源码

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

项目:bnpy 作者: bnpy 项目源码 文件源码
def mapToNewPos(curposIDs, bigtosmall):
    ''' Convert list of old ids to new positions after bigtosmall reordering.

    Example
    -------
    >>> curposIDs = [0, 2, 4]
    >>> N = [11, 9, 3, 1, 5]
    >>> bigtosmall = argsort_bigtosmall_stable(N)
    >>> print bigtosmall
    [0 1 4 2 3]
    >>> newposIDs = mapToNewPos(curposIDs, bigtosmall)
    >>> print newposIDs
    [0, 3, 2]
    '''
    newposIDs = np.zeros_like(curposIDs)
    for posID in range(len(curposIDs)):
        newposIDs[posID] = np.flatnonzero(bigtosmall == curposIDs[posID])[0]
    return newposIDs.tolist()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号