Skip to content

TYP: clip improved shape-typing and dtype propagation - #32204

Merged
charris merged 1 commit into
numpy:mainfrom
jorenham:typing/clip/improve-shape-typing
Aug 7, 2026
Merged

charris merged 1 commit into
numpy:mainfrom
jorenham:typing/clip/improve-shape-typing

Conversation

@jorenham

@jorenham jorenham commented Aug 5, 2026

Copy link
Copy Markdown
Member

np.clip now also propagates the input shape-type and input dtype in more common cases.

Note however that there is still room for (shape-typing) improvement, because the broadcasting behavior of a_min and a_max is currently not taken into account (doing so would result in a combinatorial explosion of overloads, so that's why).

Passing these as scalars is by far the most common usecase though, so I don't think that all of these additional overloads are worth it, and I'll just mark this as "done" in https://gist.github.com/jorenham/36c78602a7ca866ddb2a917de48ccdd0.


Fully written by me, audited as kinda-high-value shape-typing improvement by AI (see https://gist.github.com/jorenham/36c78602a7ca866ddb2a917de48ccdd0).

@jorenham jorenham added this to the 2.6.0 Release milestone Aug 5, 2026
@charris
charris merged commit 57cd86e into numpy:main Aug 7, 2026
15 checks passed
@charris

charris commented Aug 7, 2026

Copy link
Copy Markdown
Member

Thanks Joren.

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.

2 participants