Skip to content
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

Numpy 2.2 abbreviations #176

Merged
merged 2 commits into from
Dec 9, 2024
Merged

Numpy 2.2 abbreviations #176

merged 2 commits into from
Dec 9, 2024

Conversation

ev-br
Copy link
Member

@ev-br ev-br commented Dec 9, 2024

NumPy 2.2 added shape= to the repr of abbreviated arrays. This is not a legal argument to array(...) constructor, thus the result cannot be eval-ed.

Thus, remove the shape=... bit, if present, from both want and got. Then try to cater for both "new" and "old" numpy outputs:

  • if shape= is present in the output, i.e. on NumPy >= 2.2, compare both shapes and values
  • if shape= is not present in the output, i.e. on NumPy < 2.2, only compare the values.

This way, doctests written in the numpy 2.2+ format, continue working across all numpy versions. Doctests written for the "old" format do not work on numpy 2.2+ and need a tweak to add shapes=....

closes gh-175

NumPy 2.2 added shape= to the repr of abbreviated arrays. This is not a
legal argument to `array(...)` constructor, thus the result cannot be eval-ed.

Handle this case by removing the shape= bit.
@ev-br ev-br added the enhancement New features w.r.t. the original refguide-check label Dec 9, 2024
@ev-br ev-br changed the title Numpy 2.2 abbrev Numpy 2.2 abbreviations Dec 9, 2024
@ev-br
Copy link
Member Author

ev-br commented Dec 9, 2024

Going to merge straight away and proceed to releasing to pypi to unblock scipy. Post-merge reviews are most welcome though.

@ev-br ev-br merged commit 4a1ff04 into main Dec 9, 2024
16 checks passed
@ev-br ev-br deleted the numpy_2.2_abbrev branch December 9, 2024 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features w.r.t. the original refguide-check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adapt to numpy==2.2 repr changes
1 participant