core.py 文件源码

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

项目:radar 作者: amoose136 项目源码 文件源码
def sort(a, axis=-1, kind='quicksort', order=None, endwith=True, fill_value=None):
    "Function version of the eponymous method."
    a = narray(a, copy=True, subok=True)
    if axis is None:
        a = a.flatten()
        axis = 0
    if fill_value is None:
        if endwith:
            # nan > inf
            if np.issubdtype(a.dtype, np.floating):
                filler = np.nan
            else:
                filler = minimum_fill_value(a)
        else:
            filler = maximum_fill_value(a)
    else:
        filler = fill_value

    sindx = filled(a, filler).argsort(axis=axis, kind=kind, order=order)

    # save meshgrid memory for 1d arrays
    if a.ndim == 1:
        indx = sindx
    else:
        indx = np.meshgrid(*[np.arange(x) for x in a.shape], sparse=True,
                           indexing='ij')
        indx[axis] = sindx
    return a[indx]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号