Skip to content

TYP: Fix overload for ma.MaskedArray.{min,max,ptp} and ma.{min,max,ptp} for positional axis and out#28637

Merged
jorenham merged 1 commit into
numpy:mainfrom
MarcoGorelli:ma-min-axis-out-fixup
Apr 3, 2025
Merged

TYP: Fix overload for ma.MaskedArray.{min,max,ptp} and ma.{min,max,ptp} for positional axis and out#28637
jorenham merged 1 commit into
numpy:mainfrom
MarcoGorelli:ma-min-axis-out-fixup

Conversation

@MarcoGorelli

@MarcoGorelli MarcoGorelli commented Apr 3, 2025

Copy link
Copy Markdown
Member

If out is passed, then that determines the return types, regardless of axis, right? Looks like I'd missed the non-None case last time

Related PRs:

@jorenham jorenham self-requested a review April 3, 2025 14:05
@jorenham

jorenham commented Apr 3, 2025

Copy link
Copy Markdown
Member

If out is passed, then that determines the return types, regardless of axis, right?

When you pass an array for out, then the function will return that very object.
There may be situations a given axis and out shape are incompatible, causing an error to be raised at runtime. But attempting to prevent this using static typing will require many overloads, and I don't think that the resulting spaghetti is worth that.

@MarcoGorelli MarcoGorelli marked this pull request as ready for review April 3, 2025 14:32

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

Good catch, and good fix!

@jorenham

jorenham commented Apr 3, 2025

Copy link
Copy Markdown
Member

Since the PR title doesn't cover all changes, could you briefly list the functions/methods that are affected by this PR? It could also be helpful to link to your previous PR's that are relevant here.

@MarcoGorelli MarcoGorelli changed the title TYP: Fix overload for MaskedArray.min when axis and out are passed positionally TYP: Fix overload for MaskedArray.min, MaskedArray.max, MaskedArray.ptp, np.ma.min, np.ma.max, and np.ma.ptp when axis and out are passed positionally Apr 3, 2025
@MarcoGorelli

Copy link
Copy Markdown
Member Author

sure, done, thanks!

@jorenham jorenham changed the title TYP: Fix overload for MaskedArray.min, MaskedArray.max, MaskedArray.ptp, np.ma.min, np.ma.max, and np.ma.ptp when axis and out are passed positionally TYP: Fix overload for ma.MaskedArray.{min,max,ptp} and ma.{min,max,ptp} for positional axis and out Apr 3, 2025
@jorenham

jorenham commented Apr 3, 2025

Copy link
Copy Markdown
Member

I condensed the title a bit; hope you don't mind.

@MarcoGorelli

Copy link
Copy Markdown
Member Author

🙌 that's better!

@jorenham jorenham merged commit dfbf9ed into numpy:main Apr 3, 2025
@jorenham

jorenham commented Apr 3, 2025

Copy link
Copy Markdown
Member

Thanks again, Marco 😄

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