Skip to content

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

Open
wants to merge 54 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
87f410b
ENH: Allocate lock only once in StringDType quicksort
MaanasArora Mar 14, 2025
ecd3ee1
ENH: Add dtype slots for sorting and begin integration
MaanasArora Mar 26, 2025
7e0bf44
MAINT: Rename sort compare slot access function
MaanasArora Mar 26, 2025
45f5008
ENH: Add dtype slot sorting functionality support to all sort kinds
MaanasArora Mar 26, 2025
d235dc9
ENH: Add descending flag to internal sorting functions
MaanasArora Mar 26, 2025
6a65c07
MAINT: Improve get dtype sort compare function name
MaanasArora Mar 27, 2025
379022f
MAINT: Fix doc typo
MaanasArora Mar 27, 2025
36fa05f
MAINT: Error out when non-legacy dtype has no sort_compare function
MaanasArora Mar 27, 2025
a7c6792
DOC: Add release notes for new dtype sorting API
MaanasArora Mar 28, 2025
84e7421
DOC: Add doc for sort compare slot in release notes
MaanasArora Mar 28, 2025
5caea7f
DOC: Add note for potential deprecation of sort arrfuncs in release note
MaanasArora Mar 30, 2025
f700725
MAINT: Reorder dtype slots to prevent changing existing slot numbers
MaanasArora Mar 30, 2025
e7cf5c2
BUG: Error on missing `sort_compare` slot only when dtype is privatel…
MaanasArora Mar 30, 2025
21fb7e7
DOC: Add C-API documentation for new sorting slots
MaanasArora Apr 1, 2025
9244ea3
ENH: Replace array object with context and auxdata in sortfunc signat…
MaanasArora Apr 5, 2025
9f09b13
BUG: Fix unnecessarily private function call due to underscore typo
MaanasArora Apr 5, 2025
7aeba26
MAINT: Fix whitespace typos
MaanasArora Apr 5, 2025
c7481b8
ENH: Allow flexible sorting compare for arr or descr in npy_sort func…
MaanasArora Apr 11, 2025
aa3415a
ENH: Add new sort func implementations and use in stringdtype
MaanasArora Apr 11, 2025
e725ed5
DOC: Fix missing newline in ctype doc
MaanasArora Apr 11, 2025
6d0ba21
DOC: Add sortfunc typedef docs
MaanasArora Apr 12, 2025
23204c5
DOC: Fix missing newline in ctype doc
MaanasArora Apr 12, 2025
ede3462
ENH: Define SortCompareFunc type
MaanasArora Apr 12, 2025
889ee11
Update dtype sorting signatures: move context, move out auxdata to ge…
MaanasArora May 13, 2025
beba242
MAINT: Check error in Get(Arg)SortFunc using return value
MaanasArora May 13, 2025
61e6f16
DOC: Add missing newlines to c-types in array.rst
MaanasArora May 14, 2025
434005e
MAINT: Rename new sort funcs and restore older names for existing pub…
MaanasArora May 24, 2025
3c168e4
MAINT: Rename start pointer in new sort func documentation to data
MaanasArora May 24, 2025
d9d9872
ENH: Add flags to new get_(arg)sort_function
MaanasArora May 28, 2025
a448475
DOC: Mention new sort func buffers to be contiguous
MaanasArora May 28, 2025
ab8f394
ENH: Elaborate new sort context, add reverse sorting and non position…
MaanasArora Jun 1, 2025
cd38b15
MAINT: Remove array from new sort context
MaanasArora Jun 1, 2025
dcc465a
DOC: Add `PyArrayMethod_SortContext` to docs
MaanasArora Jun 1, 2025
30b6c9c
DOC: Move sort nan position enum to array.rst
MaanasArora Jun 1, 2025
60d7f80
DOC: Add accidentally removed documentation for finalize_descr slot
MaanasArora Jun 1, 2025
38e29e0
BUG: Fix context initiation in _new_(arg)sortlike
MaanasArora Jun 1, 2025
bbbd274
ENH: Add descending flag to SortContext
MaanasArora Jun 1, 2025
178445d
MAINT: Pass descr in sort compare func and remove compare slot
MaanasArora Jul 1, 2025
29cd764
MAINT: Remove name for only one parameter in typedef
MaanasArora Jul 1, 2025
852783f
ENH: Add NumPy 2.4 API version and use for new sorting slots
MaanasArora Jul 1, 2025
5aaa15f
ENH: Add error result to `NPY_COMPARE_RESULT` enum
MaanasArora Jul 1, 2025
28e8c3a
DOC: Fix incorrectly changed arrfunc docs for sort functions
MaanasArora Jul 3, 2025
6e65f8d
MAINT: Clearer names for NPY_SORT_NAN_POSITION members
MaanasArora Jul 3, 2025
73bb5f8
DOC: Remove unimplemented release note
MaanasArora Jul 3, 2025
5eca653
DOC: Document new-style sorts are always descending and nan to end
MaanasArora Jul 3, 2025
9d3ae70
MAINT: Remove descending from get_sort_function and rename in sort co…
MaanasArora Jul 3, 2025
f46a498
DOC: Add version added directives to new sorting slots
MaanasArora Jul 3, 2025
b471562
BUG: Check return value of slots in GetSortFunction and GetArgSortFun…
MaanasArora Jul 3, 2025
d022a2d
DOC: Clarify that comparison function pointer can be NULL in sorting …
MaanasArora Jul 3, 2025
b1222b2
BUG: Use NPY_MIN_INT return value in compare_from_context to indicate…
MaanasArora Jul 3, 2025
4d7d592
DOC: Add release note for new sort compare c-api change
MaanasArora Jul 5, 2025
b734527
DOC: Add `PyArray_SortCompareFunc` to array docs
MaanasArora Jul 5, 2025
7d9ac65
DOC: Update sorting documentation with NPY_COMPARE_RESULT enum
MaanasArora Jul 5, 2025
c21a164
ENH: Add descending sorts to new `compare_from_context`
MaanasArora Jul 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
DOC: Add version added directives to new sorting slots
  • Loading branch information
MaanasArora committed Jul 3, 2025
commit f46a49817b6052a1071fe77b83ad7b056e61d6fb
6 changes: 6 additions & 0 deletions doc/source/reference/c-api/array.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3549,6 +3549,8 @@ member of ``PyArrayDTypeMeta_Spec`` struct.
npy_intp sort_kind, PyArray_SortFuncWithContext **out_sort, \
NpyAuxData **out_auxdata, NPY_ARRAYMETHOD_FLAGS *out_flags)

.. versionadded:: 2.4

If defined, sets a custom sorting function for the DType for each of
the sort kinds numpy implements. Currently, sorts are always descending
and always use nulls to the end, and this must be checked in the
Expand All @@ -3560,13 +3562,17 @@ member of ``PyArrayDTypeMeta_Spec`` struct.
npy_intp sort_kind, PyArray_ArgSortFuncWithContext **out_argsort, \
NpyAuxData **out_auxdata, NPY_ARRAYMETHOD_FLAGS *out_flags)

.. versionadded:: 2.4

If defined, sets a custom argsorting function for the DType for each of
the sort kinds numpy implements. Currently, sorts are always descending
and always use nulls to the end, and this must be checked in the
implementation. Returns 0 on success.

.. c:macro:: NPY_DT_sort_compare

.. versionadded:: 2.4

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``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a .. versionadded:: here. We don't have to strictly hide it, since it'll at least fail gracefully on older versions (at least I hope).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks

Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy