-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
ENH, API: New sorting mechanism for DType API #28516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 37 commits
87f410b
ecd3ee1
7e0bf44
45f5008
d235dc9
6a65c07
379022f
36fa05f
a7c6792
84e7421
5caea7f
f700725
e7cf5c2
21fb7e7
9244ea3
9f09b13
7aeba26
c7481b8
aa3415a
e725ed5
6d0ba21
23204c5
ede3462
889ee11
beba242
61e6f16
434005e
3c168e4
d9d9872
a448475
ab8f394
cd38b15
dcc465a
30b6c9c
60d7f80
38e29e0
bbbd274
178445d
29cd764
852783f
5aaa15f
28e8c3a
6e65f8d
73bb5f8
5eca653
9d3ae70
f46a498
b471562
d022a2d
b1222b2
4d7d592
b734527
7d9ac65
c21a164
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* `PyArray_GetSortFunction`, `PyArray_GetArgSortFunction`, and `PyArray_GetSortCompareFunction` have been added to the C-API. These functions return the sorting, argsorting, and sort comparison functions if provided for a given dtype in new slots. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
New sorting function slots `NPY_DT_get_sort_function`, `NPY_DT_get_argsort_function` for dtype API | ||
--------------------------------------------------------------------------------------------------- | ||
|
||
User-defined dtypes can now provide specific sorting functions for use with NumPy's sort methods. | ||
The new slots `NPY_DT_get_sort_function` and `NPY_DT_get_argsort_function` should be functions that | ||
return function pointers implementing sorting functionality for the dtype, while considering the | ||
sort-kind and order. The old arrfunc slots ``NPY_DT_PyArray_ArrFuncs_sort`` and | ||
``NPY_DT_PyArray_ArrFuncs_argsort`` may be deprecated in the future. | ||
|
||
Additionally, the new `NPY_DT_sort_compare` slot can be used to provide a comparison function for | ||
sorting, which will replace the default comparison function for the dtype in sorting functions. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe a note that the old arrfuncs slots may be deprecated in the future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added, thanks! |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1873,6 +1873,28 @@ described below. | |
pointer. Currently this is used for zero-filling and clearing arrays storing | ||
embedded references. | ||
|
||
.. c:type:: int (PyArray_SortFuncWithContext)( \ | ||
PyArrayMethod_SortContext *context, void *data, \ | ||
npy_intp num, NpyAuxData *auxdata) | ||
|
||
A function to sort a buffer of data. The *data* is a pointer to the | ||
beginning of the contiguous buffer containing *num* elements. A function | ||
of this type is returned by the `get_sort_function` function in the DType | ||
slots, where *context* is passed in containing the descriptor for the | ||
array. Returns 0 on success, -1 on failure. | ||
|
||
.. c:type:: int (PyArray_ArgSortFuncWithContext)( \ | ||
PyArrayMethod_SortContext *context, void *data, \ | ||
npy_intp *tosort, npy_intp num, NpyAuxData *auxdata) | ||
|
||
A function to arg-sort a buffer of data. The *data* is a pointer to the | ||
beginning of the buffer containing *num* elements. The *tosort* is a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @charris to confirm, even for argsorting it probably makes sense to always use a contiguous buffer for sorting? |
||
pointer to an array of indices that will be filled in with the | ||
indices of the sorted elements. A function of this type is returned by | ||
the `get_argsort_function` function in the DType slots, where | ||
*context* is passed in containing the descriptor for the array. | ||
Returns 0 on success, -1 on failure. | ||
|
||
API Functions and Typedefs | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
|
@@ -3521,6 +3543,30 @@ member of ``PyArrayDTypeMeta_Spec`` struct. | |
force newly created arrays to have a newly created descriptor | ||
instance, no matter what input descriptor is provided by a user. | ||
|
||
.. c:macro:: NPY_DT_get_sort_function | ||
|
||
.. c:type:: int *(PyArrayDTypeMeta_GetSortFunction)(PyArray_Descr *, \ | ||
npy_intp sort_kind, int descending, PyArray_SortFuncWithContext **out_sort, \ | ||
seberg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
NpyAuxData **out_auxdata, NPY_ARRAYMETHOD_FLAGS *out_flags) | ||
|
||
If defined, sets a custom sorting function for the DType for each of | ||
the sort kinds numpy implements. Returns 0 on success. | ||
|
||
.. c:macro:: NPY_DT_get_argsort_function | ||
|
||
.. c:type:: int *(PyArrayDTypeMeta_GetArgSortFunction)(PyArray_Descr *, \ | ||
npy_intp sort_kind, int descending, PyArray_ArgSortFuncWithContext **out_argsort, \ | ||
NpyAuxData **out_auxdata, NPY_ARRAYMETHOD_FLAGS *out_flags) | ||
|
||
If defined, sets a custom argsorting function for the DType for each of | ||
the sort kinds numpy implements. Returns 0 on success. | ||
|
||
.. c:macro:: NPY_DT_sort_compare | ||
|
||
If defined, sets a custom comparison function for the DType for use in | ||
sorting, which will replace `NPY_DT_PyArray_ArrFuncs_compare`. Implements | ||
``PyArray_CompareFunc``. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, thanks |
||
|
||
PyArray_ArrFuncs slots | ||
^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
|
@@ -3547,6 +3593,8 @@ DType API slots but for now we have exposed the legacy | |
.. c:macro:: NPY_DT_PyArray_ArrFuncs_compare | ||
|
||
Computes a comparison for `numpy.sort`, implements ``PyArray_CompareFunc``. | ||
If `NPY_DT_sort_compare` is defined, it will be used instead. This slot may | ||
be deprecated in the future. | ||
|
||
.. c:macro:: NPY_DT_PyArray_ArrFuncs_argmax | ||
|
||
|
@@ -3588,15 +3636,19 @@ DType API slots but for now we have exposed the legacy | |
|
||
.. c:macro:: NPY_DT_PyArray_ArrFuncs_sort | ||
|
||
An array of PyArray_SortFunc of length ``NPY_NSORTS``. If set, allows | ||
An array of PyArray_SortFuncWithContext of length ``NPY_NSORTS``. If set, allows | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems wrong, should be unchanged? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's wrong, thanks for catching |
||
defining custom sorting implementations for each of the sorting | ||
algorithms numpy implements. | ||
algorithms numpy implements. If `NPY_DT_get_sort_function` is | ||
defined, it will be used instead. This slot may be deprecated in the | ||
future. | ||
|
||
.. c:macro:: NPY_DT_PyArray_ArrFuncs_argsort | ||
|
||
An array of PyArray_ArgSortFunc of length ``NPY_NSORTS``. If set, | ||
An array of PyArray_ArgSortFuncWithContext of length ``NPY_NSORTS``. If set, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, should remain unchanged. |
||
allows defining custom argsorting implementations for each of the | ||
sorting algorithms numpy implements. | ||
sorting algorithms numpy implements. If `NPY_DT_get_argsort_function` | ||
is defined, it will be used instead. This slot may be deprecated in | ||
the future. | ||
|
||
Macros and Static Inline Functions | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
@@ -4340,6 +4392,17 @@ Enumerated Types | |
:c:data:`NPY_STABLESORT` are aliased to each other and may refer to one | ||
of several stable sorting algorithms depending on the data type. | ||
|
||
.. c:enum:: NPY_SORT_NAN_POSITION | ||
|
||
An enum used to indicate the position of NaN values in sorting. | ||
|
||
.. c:enumerator:: NPY_SORT_NAN_FIRST | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer I.e. make it sort order independent. first/last to me seems slightly less clear whether it is sort order dependent or not (i.e. does "first" mean that it's value is considered lower than others?). (The problem is, that in practice both conventions are relatively common.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've used |
||
|
||
Indicates that NaN values should be sorted first. | ||
|
||
.. c:enumerator:: NPY_SORT_NAN_LAST | ||
|
||
Indicates that NaN values should be sorted last. | ||
|
||
.. c:enum:: NPY_SCALARKIND | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -494,8 +494,8 @@ PyArray_ArrFuncs | |
PyArray_NonzeroFunc *nonzero; | ||
PyArray_FillFunc *fill; | ||
PyArray_FillWithScalarFunc *fillwithscalar; | ||
PyArray_SortFunc *sort[NPY_NSORTS]; | ||
PyArray_ArgSortFunc *argsort[NPY_NSORTS]; | ||
PyArray_SortFuncWithContext *sort[NPY_NSORTS]; | ||
PyArray_ArgSortFuncWithContext *argsort[NPY_NSORTS]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You really can't change this! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, reverted! |
||
PyObject *castdict; | ||
PyArray_ScalarKindFunc *scalarkind; | ||
int **cancastscalarkindto; | ||
|
@@ -792,6 +792,40 @@ PyArrayMethod_Context and PyArrayMethod_Spec | |
An array of slots for the method. Slot IDs must be one of the values | ||
below. | ||
|
||
.. _arraymethod-sort-context: | ||
|
||
PyArrayMethod_SortContext | ||
------------------------- | ||
|
||
.. c:type:: PyArrayMethod_SortContext | ||
|
||
A struct used to provide context for sorting methods. | ||
|
||
.. code-block:: c | ||
|
||
typedef struct { | ||
PyArray_Descr *descriptor; | ||
PyArray_SortCompareFunc *compare; | ||
int reversed; | ||
NPY_SORT_NAN_POSITION nan_position; | ||
} PyArrayMethod_SortContext | ||
|
||
.. c:member:: PyArray_Descr *descriptor | ||
|
||
The descriptor for the data type being sorted. | ||
|
||
.. c:member:: PyArray_SortCompareFunc *compare | ||
|
||
A pointer to the comparison function used for sorting. | ||
seberg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. c:member:: int reversed | ||
|
||
A flag indicating whether the sort is reversed. | ||
|
||
.. c:member:: NPY_SORT_NAN_POSITION nan_position | ||
|
||
The position of NaN values in the sort order. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, makes sense to pass these as information, and I guess that means it makes sense to use a custom context and not try to rely on an existing one (the ufunc/casting one is more complex, and the traverse one too simple maybe.) Strictly speaking, we could avoid the sortcompare slot here, but I think it's maybe pragmatic to just include it and leave it NULL. |
||
|
||
.. _dtypemeta: | ||
|
||
PyArray_DTypeMeta and PyArrayDTypeMeta_Spec | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -367,6 +367,10 @@ typedef int (PyArrayMethod_PromoterFunction)(PyObject *ufunc, | |||||
#define NPY_DT_get_clear_loop 9 | ||||||
#define NPY_DT_get_fill_zero_loop 10 | ||||||
#define NPY_DT_finalize_descr 11 | ||||||
#define NPY_DT_get_sort_function 12 | ||||||
#define NPY_DT_get_argsort_function 13 | ||||||
#define NPY_DT_compare 14 | ||||||
#define NPY_DT_sort_compare 15 | ||||||
|
||||||
// These PyArray_ArrFunc slots will be deprecated and replaced eventually | ||||||
// getitem and setitem can be defined as a performance optimization; | ||||||
|
@@ -477,4 +481,47 @@ typedef PyArray_Descr *(PyArrayDTypeMeta_FinalizeDescriptor)(PyArray_Descr *dtyp | |||||
typedef int(PyArrayDTypeMeta_SetItem)(PyArray_Descr *, PyObject *, char *); | ||||||
typedef PyObject *(PyArrayDTypeMeta_GetItem)(PyArray_Descr *, char *); | ||||||
|
||||||
typedef enum { | ||||||
NPY_LESS = -1, | ||||||
NPY_EQUAL = 0, | ||||||
NPY_GREATER = 1, | ||||||
NPY_UNORDERED_LEFT = 2, | ||||||
NPY_UNORDERED_RIGHT = 3, | ||||||
NPY_UNORDERED_BOTH = 4, | ||||||
} NPY_COMPARE_RESULT; | ||||||
|
||||||
typedef struct PyArrayMethod_SortContext_tag PyArrayMethod_SortContext; | ||||||
|
||||||
typedef NPY_COMPARE_RESULT (PyArray_CompareFuncWithContext)( | ||||||
const void *a, const void *b, PyArrayMethod_SortContext *context); | ||||||
typedef NPY_COMPARE_RESULT (PyArray_SortCompareFunc)( | ||||||
const void *a, const void *b, PyArrayMethod_SortContext *context); | ||||||
|
||||||
typedef enum { | ||||||
NPY_SORT_NAN_FIRST = 0, | ||||||
NPY_SORT_NAN_LAST = 1, | ||||||
} NPY_SORT_NAN_POSITION; | ||||||
|
||||||
struct PyArrayMethod_SortContext_tag { | ||||||
PyArray_Descr *descriptor; | ||||||
PyArray_SortCompareFunc *compare; | ||||||
int descending; | ||||||
int reversed; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same paremeter, should just be descending. Could make it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, done and made |
||||||
NPY_SORT_NAN_POSITION nan_position; | ||||||
}; | ||||||
|
||||||
typedef int (PyArray_SortFuncWithContext)(PyArrayMethod_SortContext *, | ||||||
void *, npy_intp, | ||||||
NpyAuxData *); | ||||||
typedef int (PyArray_ArgSortFuncWithContext)(PyArrayMethod_SortContext *, | ||||||
void *, npy_intp *, npy_intp, | ||||||
NpyAuxData *); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two need different names and you need to leave the original typedefs in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for reviewing! This is done. |
||||||
|
||||||
typedef int *(PyArrayDTypeMeta_GetSortFunction)(PyArray_Descr *, | ||||||
npy_intp, int, PyArray_SortFuncWithContext **, NpyAuxData **, | ||||||
NPY_ARRAYMETHOD_FLAGS *out_flags); | ||||||
typedef int *(PyArrayDTypeMeta_GetArgSortFunction)(PyArray_Descr *, | ||||||
npy_intp, int, PyArray_ArgSortFuncWithContext **, NpyAuxData **, | ||||||
NPY_ARRAYMETHOD_FLAGS *out_flags); | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New stuff in the public API needs new API docs as well as a release note describing the new features. Maybe also as a proof-of-concept, it looks like both quaddtype and mpfdtype in numpy-user-dtypes implement sorting - would you be willing to update them to use the new API in a PR to numpy-user-dtypes that depends on this PR to numpy? That should give you a feeling for whether this API is helpful for someone writing a new user dtype. It'll also be a form of documentation - we don't have great docs for writing user dtypes besides the examples in numpy-user-dtypes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also what should we do about the flags that got added before we made the dtype API public, e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's easy to generate a deprecation warning during registration (a bit tedious maybe, as you need explicit check). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I'll add API docs and a release note, and willing to make a PR to numpy-user-dtypes! Will look into that. Just to be clear, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't change slot numbers (unless they are guarded as private)! So the numbers are fixed (until they have not been used for a bit at least). So, we just have to live with the numbering we got, I half thought I asked for an offset for the [^depr] I think this is as simple as asking users to compile with the new NumPy, and then adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There is an offset, numpy/numpy/_core/src/multiarray/dtypemeta.h Lines 94 to 95 in 9389862
|
||||||
#endif /* NUMPY_CORE_INCLUDE_NUMPY___DTYPE_API_H_ */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -192,6 +192,10 @@ dtypemeta_initialize_struct_from_spec( | |
NPY_DT_SLOTS(DType)->common_instance = NULL; | ||
NPY_DT_SLOTS(DType)->setitem = NULL; | ||
NPY_DT_SLOTS(DType)->getitem = NULL; | ||
NPY_DT_SLOTS(DType)->get_sort_function = NULL; | ||
NPY_DT_SLOTS(DType)->get_argsort_function = NULL; | ||
NPY_DT_SLOTS(DType)->compare = NULL; | ||
NPY_DT_SLOTS(DType)->sort_compare = NULL; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. must come at the end to not break ABI! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is done! |
||
NPY_DT_SLOTS(DType)->get_clear_loop = NULL; | ||
NPY_DT_SLOTS(DType)->get_fill_zero_loop = NULL; | ||
NPY_DT_SLOTS(DType)->finalize_descr = NULL; | ||
|
@@ -1230,6 +1234,20 @@ dtypemeta_wrap_legacy_descriptor( | |
dtype_class->flags |= NPY_DT_NUMERIC; | ||
} | ||
|
||
if (dt_slots->sort_compare == NULL) { | ||
ngoldbaum marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!NPY_DT_is_legacy(dtype_class) && !NPY_DT_is_user_defined(dtype_class)) { | ||
PyErr_SetString(PyExc_RuntimeError, | ||
"DType has no sort_compare function."); | ||
ngoldbaum marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Py_DECREF(dtype_class); | ||
return -1; | ||
} | ||
} | ||
|
||
/* Auto-fill compare slot with sort-compare as default */ | ||
if (dt_slots->compare == NULL && dt_slots->sort_compare != NULL) { | ||
dt_slots->compare = dt_slots->sort_compare; | ||
} | ||
seberg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (_PyArray_MapPyTypeToDType(dtype_class, descr->typeobj, | ||
PyTypeNum_ISUSERDEF(dtype_class->type_num)) < 0) { | ||
Py_DECREF(dtype_class); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,13 @@ typedef struct { | |
* parameters, if any, as the operand dtype. | ||
*/ | ||
PyArrayDTypeMeta_FinalizeDescriptor *finalize_descr; | ||
|
||
/* DType sorting methods. */ | ||
PyArrayDTypeMeta_GetSortFunction *get_sort_function; | ||
PyArrayDTypeMeta_GetArgSortFunction *get_argsort_function; | ||
PyArray_CompareFuncWithContext *compare; | ||
PyArray_SortCompareFunc *sort_compare; | ||
|
||
/* | ||
* The casting implementation (ArrayMethod) to convert between two | ||
* instances of this DType, stored explicitly for fast access: | ||
|
@@ -89,7 +96,7 @@ typedef struct { | |
|
||
// This must be updated if new slots before within_dtype_castingimpl | ||
// are added | ||
#define NPY_NUM_DTYPE_SLOTS 11 | ||
#define NPY_NUM_DTYPE_SLOTS 15 | ||
#define NPY_NUM_DTYPE_PYARRAY_ARRFUNCS_SLOTS 22 | ||
#define NPY_DT_MAX_ARRFUNCS_SLOT \ | ||
NPY_NUM_DTYPE_PYARRAY_ARRFUNCS_SLOTS + _NPY_DT_ARRFUNCS_OFFSET | ||
|
@@ -291,6 +298,45 @@ PyArray_SETITEM(PyArrayObject *arr, char *itemptr, PyObject *v) | |
Py_XSETREF(descr, _new_); \ | ||
} while(0) | ||
|
||
static inline int | ||
PyArray_GetSortFunction(PyArray_Descr *descr, | ||
NPY_SORTKIND which, int descending, PyArray_SortFuncWithContext **out_sort, | ||
NpyAuxData **out_auxdata, NPY_ARRAYMETHOD_FLAGS *out_flags) | ||
{ | ||
if (NPY_DT_SLOTS(NPY_DTYPE(descr))->get_sort_function == NULL) { | ||
return -1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to set an error (TypeError or DTypeTypeError, which is defined somewhere I think.) (An error here will make sense after you move the fallback logic into a default slot filling. Or you could have the default slot raise an error, that is also completely fine.) |
||
} | ||
|
||
NPY_DT_SLOTS(NPY_DTYPE(descr))->get_sort_function( | ||
descr, which, descending, out_sort, out_auxdata, out_flags); | ||
return 0; | ||
} | ||
|
||
static inline int | ||
PyArray_GetArgSortFunction(PyArray_Descr *descr, | ||
NPY_SORTKIND which, int descending, PyArray_ArgSortFuncWithContext **out_argsort, | ||
NpyAuxData **out_auxdata, NPY_ARRAYMETHOD_FLAGS *out_flags) | ||
{ | ||
if (NPY_DT_SLOTS(NPY_DTYPE(descr))->get_argsort_function == NULL) { | ||
return -1; | ||
} | ||
|
||
NPY_DT_SLOTS(NPY_DTYPE(descr))->get_argsort_function( | ||
seberg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
descr, which, descending, out_argsort, out_auxdata, out_flags); | ||
return 0; | ||
} | ||
|
||
static inline PyArray_CompareFuncWithContext * | ||
PyArray_GetCompareFunction(PyArray_Descr *descr) | ||
{ | ||
return NPY_DT_SLOTS(NPY_DTYPE(descr))->compare; | ||
} | ||
|
||
static inline PyArray_SortCompareFunc * | ||
PyArray_GetSortCompareFunction(PyArray_Descr *descr) | ||
{ | ||
return NPY_DT_SLOTS(NPY_DTYPE(descr))->sort_compare; | ||
} | ||
|
||
// Get the pointer to the PyArray_DTypeMeta for the type associated with the typenum. | ||
static inline PyArray_DTypeMeta * | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You did not actually add them to the public C-API. Which is totally fine, though.
(I might start with adding a
SortBuffer()
function or so.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is still valid, I think we might as well remove this for now.