[BUG, REFAC]: Simplifies quad_ufunc_promoter + fixes reduction bug in comparison_ufunc_promoter#79
Open
SwayamInSync wants to merge 3 commits intonumpy:mainfrom
Open
[BUG, REFAC]: Simplifies quad_ufunc_promoter + fixes reduction bug in comparison_ufunc_promoter#79SwayamInSync wants to merge 3 commits intonumpy:mainfrom
quad_ufunc_promoter + fixes reduction bug in comparison_ufunc_promoter#79SwayamInSync wants to merge 3 commits intonumpy:mainfrom
Conversation
- Fix quad_ufunc_promoter, quad_ldexp_promoter, and comparison_ufunc_promoter signatures to match PyArrayMethod_PromoterFunction typedef: (PyObject *, PyArray_DTypeMeta *const[], PyArray_DTypeMeta *const[], PyArray_DTypeMeta *[]) - Add missing Py_DECREF(ufunc) in all create_quad_*_ufunc error/success return paths (binary_ops, comparison_ops, unary_ops, unary_props) - Add missing Py_INCREF before Py_XSETREF in comparison_ufunc_promoter
- quad_ufunc_promoter: Remove dead has_quad/common/PyArray_PromoteDTypeSequence machinery. Since this promoter is only registered for patterns where at least one input is QuadPrecDType, we always promote to QuadPrecDType directly. The old fallback paths were unreachable and had a refcount bug (Py_XDECREF on a borrowed pointer when has_quad was true). - comparison_ufunc_promoter: Rewrite with self-contained logic instead of delegating to quad_ufunc_promoter. Fixes reduction path which incorrectly set accumulator to QuadPrecDType instead of BoolDType (the registered reduce loop expects Bool, Quad, Bool).
SwayamInSync
commented
Apr 1, 2026
Member
Author
SwayamInSync
left a comment
There was a problem hiding this comment.
These are the only functions updated in this PR
SwayamInSync
commented
Apr 1, 2026
| inline int | ||
| quad_ufunc_promoter(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtypes[], | ||
| PyArray_DTypeMeta *signature[], PyArray_DTypeMeta *new_op_dtypes[]) | ||
| quad_ufunc_promoter(PyObject *ufunc_obj, PyArray_DTypeMeta *const op_dtypes[], |
SwayamInSync
commented
Apr 1, 2026
| NPY_NO_EXPORT int | ||
| comparison_ufunc_promoter(PyUFuncObject *ufunc, PyArray_DTypeMeta *op_dtypes[], | ||
| PyArray_DTypeMeta *signature[], PyArray_DTypeMeta *new_op_dtypes[]) | ||
| comparison_ufunc_promoter(PyObject *ufunc_obj, PyArray_DTypeMeta *const op_dtypes[], |
Member
|
Sorry, not quite clear from the description here and in the other PR: this is an alternative to #78 and we shouldn't merge both, right? |
Member
|
Oh no never mind, this just depends on the other one. |
Member
Author
|
No its first merge the #78 and then this one So I thought to keep these changes in isolation in a new PR (here) |
Member
|
This needs an update now that the PR is merged. |
Member
Author
|
Done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Successor of #78
Recommend to check after closing the #78 (for better diff) otherwise the updated sections are listed below