Skip to content

MAINT: remove unnecessary kwargs update in MaskedArray.reshape #29403

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 1 commit into from
Jul 31, 2025

Conversation

MarcoGorelli
Copy link
Member

I was working on the type annotations for MaskedArray.reshape and looked into the implementation, and noticed there's an unnecessary update to kwargs

The line

kwargs.update(order=kwargs.get('order', 'C'))

sets 'C' as the default if order wasn't passed, else it keeps what the user passed. This then gets passed to ndarray.reshape in

result = self._data.reshape(*s, **kwargs).view(type(self))

and

result._mask = mask.reshape(*s, **kwargs)

However, order='C' is already the default for ndarray.reshape

@array_function_dispatch(_reshape_dispatcher)
def reshape(a, /, shape=None, order='C', *, newshape=None, copy=None):

@MarcoGorelli MarcoGorelli marked this pull request as ready for review July 21, 2025 20:01
@seberg
Copy link
Member

seberg commented Jul 31, 2025

Agreed, seems rather useless and any reasonable _data should use the same convention.

@seberg seberg merged commit 4126291 into numpy:main Jul 31, 2025
77 checks passed
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.

3 participants