Skip to content

ENH: specific exception type for no reduction loop found - #33577

Open
ikrommyd wants to merge 5 commits into
numpy:mainfrom
ikrommyd:no-reduction-loop-error
Open

ikrommyd wants to merge 5 commits into
numpy:mainfrom
ikrommyd:no-reduction-loop-error

Conversation

@ikrommyd

@ikrommyd ikrommyd commented Dec 3, 2026

Copy link
Copy Markdown
Member

PR summary

Implements a specific exception type that we call _UFuncNoReductionLoopError and is a subclass of _UFuncNoLoopError (which all the way up is a subclass of TypeError) to make the error message of when no reduction loop of this specific type.

The idea is that if a ufunc has forwards loops and solves for the dtypes but no matching reduction loop, we get back a specific exception type that we can handle in a specific way. I found this while adding minimummaximum (+ reduction) loops to quaddtype.

AI Disclosure

No AI

Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
@jorenham

jorenham commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Two PRs addressing ufunc exceptions within 5 minutes: #33576
That's pretty exceptional!

@ikrommyd

ikrommyd commented Dec 3, 2026 •

Copy link
Copy Markdown
Member Author

It was Nathan dm'ing me about the PR he was about to open that prompted me haha. I had this on my fork for a few days.

@jorenham jorenham left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Stub changes look good (that Final is a nice touch 👌)

Comment thread numpy/_core/_exceptions.py Resolved
Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
Signed-off-by: Iason Krommydas <iason.krom@gmail.com>

@ngoldbaum ngoldbaum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems reasonable to me.

@seberg @mhvk do you two have opinions maybe?

This needs a release note (doesn't need to be lengthy) to be mergeable.

Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
@ikrommyd

ikrommyd commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

Pushed a release note.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants