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