Skip to content

BUG: NEP 50 promotion for python scalars in ufunc.outer - #32090

Merged
ngoldbaum merged 5 commits into
numpy:mainfrom
ikrommyd:ufunc-outer-nep50
Jul 29, 2026
Merged

ngoldbaum merged 5 commits into
numpy:mainfrom
ikrommyd:ufunc-outer-nep50

Conversation

@ikrommyd

@ikrommyd ikrommyd commented Jul 24, 2026 •

Copy link
Copy Markdown
Member

PR summary

Closes #32076

ufunc.outer converted its inputs to arrays before the ufunc machinery saw them, so Python scalars lost their NEP 50 weak typing: np.add.outer(1.0, f32_arr) gave float64 where np.add(1.0, f32_arr) gives float32.
Scalars are now passed on unconverted. Huge Python integers now raise OverflowError here, matching ufunc.__call__.

First time committer introduction

N/A

AI Disclosure

Ran it through AI for review and it only touched the wording on the release note.

@ikrommyd ikrommyd changed the title BUG: NEP-50 promotion for ufunc.outer BUG: NEP 50 promotion for python scalars in ufunc.outer Jul 24, 2026
Signed-off-by: Iason Krommydas <[email protected]>
Signed-off-by: Iason Krommydas <[email protected]>
@ikrommyd

ikrommyd commented Jul 24, 2026 •

Copy link
Copy Markdown
Member Author

I'd argue that my last commit makes the code more readable but moves things around a little more. Happy to adjust but I generally prefer more readable control flow.

@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.

Overall looks good, just a few minor issues. Thanks for taking this on :)

Comment thread numpy/_core/src/umath/ufunc_object.c Resolved
Comment thread numpy/_core/src/umath/ufunc_object.c Resolved
Comment thread numpy/_core/src/umath/ufunc_object.c Resolved

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! Two really small comments only.

Comment thread numpy/_core/src/umath/ufunc_object.c Resolved
Comment thread numpy/_core/src/umath/ufunc_object.c Resolved
Signed-off-by: Iason Krommydas <[email protected]>
@ikrommyd

Copy link
Copy Markdown
Member Author

I think I have addressed both reviews :)

@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.

I think this is good and I also think it's probably fine to just change this and #32094 in the release without a deprecation to make NumPy more consistent.

That said, I'd appreciate it if @seberg could confirm - can we get away without a deprecation cycle like we did for the "main" NEP-50 transition?

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! Still a tiny suggestion of nomenclature, but approving now.

Comment thread numpy/_core/src/umath/ufunc_object.c Resolved
Signed-off-by: Iason Krommydas <[email protected]>
@ikrommyd

Copy link
Copy Markdown
Member Author

I think this is good and I also think it's probably fine to just change this and #32094 in the release without a deprecation to make NumPy more consistent.

That said, I'd appreciate it if @seberg could confirm - can we get away without a deprecation cycle like we did for the "main" NEP-50 transition?

As a user, I probably wouldn't want this backported cause the change of behavior for large python integers might surprise some people but for 2.6.0 I wouldn't complain at all. All that is with my user's hat on.

@ngoldbaum

Copy link
Copy Markdown
Member

Sebastian told me to stop worrying about getting his eyes on stuff. In it goes!

@ngoldbaum
ngoldbaum merged commit 4350526 into numpy:main Jul 29, 2026
91 checks passed
@ikrommyd
ikrommyd deleted the ufunc-outer-nep50 branch July 29, 2026 15:09
ngoldbaum pushed a commit to ngoldbaum/numpy that referenced this pull request Sep 8, 2026
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.

BUG: NEP 50 promotion for python scalars is not followed for <ufunc>.outer and <ufunc>.at

4 participants