-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
ENH: New-style sorting for StringDType #30112
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
Changes from all commits
220338d
ce3f070
d4aa6c7
2fcc5c5
ff1d631
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 |
|---|---|---|
|
|
@@ -1227,7 +1227,7 @@ _new_sortlike(PyArrayObject *op, int axis, PyArray_SortFunc *sort, | |
| return 0; | ||
| } | ||
|
|
||
| if (method_flags != NULL) { | ||
| if (strided_loop != NULL) { | ||
| needs_api = *method_flags & NPY_METH_REQUIRES_PYAPI; | ||
| } | ||
| else { | ||
|
|
@@ -1441,7 +1441,7 @@ _new_argsortlike(PyArrayObject *op, int axis, PyArray_ArgSortFunc *argsort, | |
| rstride = PyArray_STRIDE(rop, axis); | ||
| needidxbuffer = rstride != sizeof(npy_intp); | ||
|
|
||
| if (method_flags != NULL) { | ||
| if (strided_loop != NULL) { | ||
|
Member
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. are the two changes above bugfixes?
Contributor
Author
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, bug fixes. This adjusts for the fact (below) that |
||
| needs_api = *method_flags & NPY_METH_REQUIRES_PYAPI; | ||
| } | ||
| else { | ||
|
|
@@ -3142,7 +3142,7 @@ PyArray_Sort(PyArrayObject *op, int axis, NPY_SORTKIND flags) | |
| PyArrayMethod_Context context = {0}; | ||
| PyArray_Descr *loop_descrs[2]; | ||
| NpyAuxData *auxdata = NULL; | ||
| NPY_ARRAYMETHOD_FLAGS *method_flags = NULL; | ||
| NPY_ARRAYMETHOD_FLAGS method_flags = 0; | ||
|
|
||
| PyArray_SortFunc **sort_table = NULL; | ||
| PyArray_SortFunc *sort = NULL; | ||
|
|
@@ -3184,7 +3184,7 @@ PyArray_Sort(PyArrayObject *op, int axis, NPY_SORTKIND flags) | |
| npy_intp strides[2] = {loop_descrs[0]->elsize, loop_descrs[1]->elsize}; | ||
|
|
||
| if (sort_method->get_strided_loop( | ||
| &context, 1, 0, strides, &strided_loop, &auxdata, method_flags) < 0) { | ||
| &context, 1, 0, strides, &strided_loop, &auxdata, &method_flags) < 0) { | ||
| ret = -1; | ||
| goto fail; | ||
| } | ||
|
|
@@ -3229,7 +3229,7 @@ PyArray_Sort(PyArrayObject *op, int axis, NPY_SORTKIND flags) | |
| } | ||
|
|
||
| ret = _new_sortlike(op, axis, sort, strided_loop, | ||
| &context, auxdata, method_flags, NULL, NULL, 0); | ||
| &context, auxdata, &method_flags, NULL, NULL, 0); | ||
|
|
||
| fail: | ||
| if (sort_method != NULL) { | ||
|
|
@@ -3259,7 +3259,7 @@ PyArray_ArgSort(PyArrayObject *op, int axis, NPY_SORTKIND flags) | |
| PyArrayMethod_Context context = {0}; | ||
| PyArray_Descr *loop_descrs[2]; | ||
| NpyAuxData *auxdata = NULL; | ||
| NPY_ARRAYMETHOD_FLAGS *method_flags = NULL; | ||
| NPY_ARRAYMETHOD_FLAGS method_flags = 0; | ||
|
|
||
| PyArray_ArgSortFunc **argsort_table = NULL; | ||
| PyArray_ArgSortFunc *argsort = NULL; | ||
|
|
@@ -3295,7 +3295,7 @@ PyArray_ArgSort(PyArrayObject *op, int axis, NPY_SORTKIND flags) | |
| npy_intp strides[2] = {loop_descrs[0]->elsize, loop_descrs[1]->elsize}; | ||
|
|
||
| if (argsort_method->get_strided_loop( | ||
| &context, 1, 0, strides, &strided_loop, &auxdata, method_flags) < 0) { | ||
| &context, 1, 0, strides, &strided_loop, &auxdata, &method_flags) < 0) { | ||
| ret = NULL; | ||
| goto fail; | ||
| } | ||
|
|
@@ -3346,7 +3346,7 @@ PyArray_ArgSort(PyArrayObject *op, int axis, NPY_SORTKIND flags) | |
| } | ||
|
|
||
| ret = _new_argsortlike(op2, axis, argsort, strided_loop, | ||
| &context, auxdata, method_flags, NULL, NULL, 0); | ||
| &context, auxdata, &method_flags, NULL, NULL, 0); | ||
| Py_DECREF(op2); | ||
|
|
||
| fail: | ||
|
|
||
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 should not be merged!!! I noticed that we actually cannot skip
resolve_descriptorsfor any parametric dtype, at least for sorts, because the output is parametric. Should we special-case somehow?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.
I didn't follow all the discussions that led to using an ArrayMethod here. I think you explained elsewhere but I'm not finding it: why don't the sort ArrayMethods care about
resolve_descriptors? Because sorts have nin = nout = 1 and the input is the output, or something along those lines? If that's what it is, maybe this check needs to be conditional on the input and output descriptors so that trivial ArrayMethods can skip it.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.
Yes, it's because the output is essentially fake for sorts (we enforce
data[0] == data[1]. Do you mean we can check if that is the case here and only error if it's not? If so makes sense -- I'll do that, thank you!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.
Sorry, I just realized this is initialization, so we don't actually have the descriptors. Not sure what the condition could be...