Skip to content

TYP: Type MaskedArray.reshape #29404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 23, 2025
Merged

Conversation

MarcoGorelli
Copy link
Member

MaskedArray.reshape only accepts *s and **kwargs as arguments. However, they get passed down as-is to ndarray.reshape:

numpy/numpy/ma/core.py

Lines 4821 to 4827 in 75e86ba

kwargs.update(order=kwargs.get('order', 'C'))
result = self._data.reshape(*s, **kwargs).view(type(self))
result._update_from(self)
mask = self._mask
if mask is not nomask:
result._mask = mask.reshape(*s, **kwargs)
return result

As noted in #29403, the kwargs update line has no effect. order is keyword-only

Given that order is keyword-only in ndarray.reshape, a call to MaskedArray.reshape is valid if and only if the same call to ndarray.reshape is.

So, I've copied over the overloads from ndarray.reshape

@jorenham jorenham added the component: numpy.ma masked arrays label Jul 21, 2025
@jorenham jorenham changed the title TYP: Type `MaskedArray.reshape TYP: Type MaskedArray.reshape Jul 21, 2025
Co-authored-by: Joren Hammudoglu <jhammudoglu@gmail.com>
@MarcoGorelli MarcoGorelli marked this pull request as ready for review July 22, 2025 07:46
@jorenham jorenham merged commit 8b2321d into numpy:main Jul 23, 2025
78 checks passed
@jorenham
Copy link
Member

Merci!

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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy