TYP: poly1d shape-typing - #32750
Merged
Merged
TYP: poly1d shape-typing#32750
poly1d shape-typing#32750Conversation
Member
|
Thanks Joren. |
Riaz1729
pushed a commit
to Riaz1729/numpy
that referenced
this pull request
Sep 23, 2026
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.
The array types of
np.poly1dare now narrowed to have 1d shape-type, because suprisingly,poly1dis 1d. There's one exception though, and that's when 0d or >1d array-likes are passed asvaltonp.poly1d.__call__, in which case the shape is preserved. So this also adds overloads to__call__so that arrays with known shape-type return an exact shape-type, and bare scalar-likes, 1d- and 2d array-like sequences also return a rank-2 array.I've used
Incompleteinstead ofAnyfor scalar-types (whichIncompletesimply aliases) because it's possible, and even feasible, to make those exact. Doing so would require turningpoly1dinto a generic type though, so that's out of scope here, and probably needs to be discussed a bit to see if we actually want to do that (seeing aspoly1dis considered legacy-ish functionality). So I guess I'll put it on the agenda for tomorrow's community meeting.Pair programmed with AI.