Skip to content

Add support for np.min and np.max to handle scalar inputs #10408 - #10435

Merged
swap357 merged 8 commits into
numba:mainfrom
davidmartinez-esc:main
Feb 19, 2026
Merged

swap357 merged 8 commits into
numba:mainfrom
davidmartinez-esc:main

Conversation

@davidmartinez-esc

@davidmartinez-esc davidmartinez-esc commented Feb 13, 2026 •

Copy link
Copy Markdown
Contributor

Added support for the np.min and np.max for scalar inputs.

I implemented the case for two functions mainly because their dual nature.

Have a nice day.

#10408

@davidmartinez-esc davidmartinez-esc changed the title Add support for np.min and np.max to handle scalar inputs #10428 Add support for np.min and np.max to handle scalar inputs ##10408 Feb 13, 2026
@davidmartinez-esc davidmartinez-esc changed the title Add support for np.min and np.max to handle scalar inputs ##10408 Add support for np.min and np.max to handle scalar inputs #10408 Feb 13, 2026

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

Thank you for the PR, @davidmartinez-esc !
I've reviewed it and left some comments below

Comment thread numba/np/arraymath.py Resolved
Comment thread numba/np/arraymath.py Resolved
Comment thread numba/tests/test_array_reductions.py Resolved
Comment thread numba/tests/test_array_reductions.py Resolved

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

one duplication to address, rest looks very good now

Comment thread numba/tests/test_array_reductions.py Resolved
@swap357 swap357 added 4 - Waiting on reviewer Waiting for reviewer to respond to author and removed 2 - In Progress labels Feb 19, 2026

@swap357 swap357 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! Thank you for your contributions to numba, @davidmartinez-esc much appreciated.

@davidmartinez-esc

Copy link
Copy Markdown
Contributor Author

Thanks for your guidance in this process and your feedback :D

Have a nice day :)

@swap357 swap357 added 5 - Ready to merge Review and testing done, is ready to merge and removed 4 - Waiting on reviewer Waiting for reviewer to respond to author labels Feb 19, 2026
@swap357
swap357 merged commit 7d1603c into numba:main Feb 19, 2026
28 checks passed
@swap357 swap357 mentioned this pull request Feb 21, 2026
7 of 17 tasks
mitre88 added a commit to mitre88/numba that referenced this pull request Mar 4, 2026
Previously, np.var and np.std would fail with a TypingError when called
with scalar inputs. This adds scalar handling following the same pattern
used in np.mean (PR numba#10428) and np.min/np.max (PR numba#10435).

For scalars, variance and standard deviation are always 0.0 (consistent
with NumPy behavior). Integer and boolean scalars return np.float64(0.0),
float scalars preserve their type, and complex scalars return
np.float64(0.0).

Partially addresses numba#10408

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5 - Ready to merge Review and testing done, is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants