2017-10-12 3 views
-3

私はnumpyの検索の実際のコードをソートしてみようとしています。私が見て:numpyの検索の実際のコードはどこですか?

https://github.com/numpy/numpy/blob/v1.13.0/numpy/core/fromnumeric.py#L1022-L1075

しかしsearchsorted機能だけを返します。_wrapfunc(a, 'searchsorted', v, side=side, sorter=sorter)

とコードの先頭には、_wrapfuncは次式で与えられます。その後、私はトラックを失う

def _wrapfunc(obj, method, *args, **kwds): 
try: 
    return getattr(obj, method)(*args, **kwds) 
    ... 

。アルゴリズム自体はどこにありますか?

答えて

3

ソースをまたいだ部分が分割されています。

スタートhere (numpy/core/src/multiarray/methods.c):その後、

array_searchsorted(PyArrayObject *self, PyObject *args, PyObject *kwds) 
.... 
return PyArray_Return((PyArrayObject *)PyArray_SearchSorted(self, keys, side, sorter)); 

here (numpy/core/src/multiarray/item_selection.c)に従ってください:

/*NUMPY_API 
* 
* Search the sorted array op1 for the location of the items in op2. The 
* result is an array of indexes, one for each element in op2, such that if 
* the item were to be inserted in op1 just before that index the array 
* would still be in sorted order. 
... 
NPY_NO_EXPORT PyObject * 
PyArray_SearchSorted(PyArrayObject *op1, PyObject *op2, 
        NPY_SEARCHSIDE side, PyObject *perm) 
{ 
... 

githubののsearch-function(私は多くの場合、numpyの/ scipyのダウンロード/ sklearnのために使用するかとの共同を使用する際に通常そのようなものが容易に発見されます。 )、可能な候補者を経て、経験のビットが早いものを取り除くことができます。ここでの検索結果の数はわずか3ページです。私は過去に悪い結果を見た。

関連する問題