grouping.py 文件源码

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

项目:pyhiro 作者: wanweiwei07 项目源码 文件源码
def unique_ordered(data):
    '''
    Returns the same as np.unique, but ordered as per the
    first occurance of the unique value in data.

    Example
    ---------
    In [1]: a = [0, 3, 3, 4, 1, 3, 0, 3, 2, 1]

    In [2]: np.unique(a)
    Out[2]: array([0, 1, 2, 3, 4])

    In [3]: trimesh.grouping.unique_ordered(a)
    Out[3]: array([0, 3, 4, 1, 2])
    '''
    data   = np.asanyarray(data)
    order  = np.sort(np.unique(data, return_index=True)[1])
    result = data[order]
    return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号