Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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

Closed
jonathanberthias opened this issue Aug 21, 2024 · 2 comments · Fixed by #27262
Closed

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

jonathanberthias opened this issue Aug 21, 2024 · 2 comments · Fixed by #27262
Assignees
Labels

Comments

@jonathanberthias
Copy link

jonathanberthias commented Aug 21, 2024

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.
@ngoldbaum
Copy link
Member

I think this was simply missed during the refactor and all that's needed is to move order to the left of the \ in the signature. @mtsokol if you have time, would you mind preparing a patch for this so it can go into 2.1.1?

@jonathanberthias if you're interested, you can set up testing against the NumPy nightly wheels to help us catch these changes before we do releases.

@mtsokol
Copy link
Member

mtsokol commented Aug 21, 2024

@ngoldbaum Sure!

@mtsokol mtsokol self-assigned this Aug 21, 2024
mtsokol added a commit to mtsokol/numpy that referenced this issue Aug 21, 2024
mtsokol added a commit to mtsokol/numpy that referenced this issue Aug 21, 2024
@mtsokol mtsokol linked a pull request Aug 21, 2024 that will close this issue
charris added a commit that referenced this issue Aug 23, 2024
charris pushed a commit to charris/numpy that referenced this issue Aug 24, 2024
charris added a commit that referenced this issue Aug 24, 2024
@charris charris removed this from the 2.1.1 release milestone Aug 28, 2024
ArvidJB pushed a commit to ArvidJB/numpy that referenced this issue Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants