Skip to content

BUG: Unexpected breaking change in np.reshape on v2.1.0 #27256

@jonathanberthias

Description

@jonathanberthias

Describe the issue:

The API for np.reshape was modified to accept all the arguments from the Array API in #26292, but there was a side effect which was not reported in the release notes of v2.1.0.

The issue is that the order argument could previously be passed by position, but now it is keyword-only.

Reproduce the code example:

import numpy as np

np.reshape(np.arange(4), (2, 2), "C")

Error message:

On v2.0.1: nothing, not even a warning

On v2.1.0:
File "/dev/np_reshape.py", line 3, in <module>
    np.reshape(np.arange(4), (2, 2), "C")
TypeError: reshape() takes from 1 to 2 positional arguments but 3 were given

Python and NumPy Versions:

2.1.0
3.12.4 (main, Jun 6 2024, 18:26:44) [GCC 11.4.0]

Runtime Environment:

No response

Context for the issue:

I don't think it's a bad thing to have to specify the order by keyword, but I think in this case the change was not intended as:

  • there was no warning in previous version,
  • there was nothing in the release notes about this,
  • in the stubs, passing order by position is valid, but not at runtime.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions