Skip to content

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
IndifferentArea pushed a commit to IndifferentArea/numpy that referenced this pull request Dec 7, 2025
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