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

Skip to content

MNT: Update basic units example to work with numpy 2.0 #28441

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
Jun 24, 2024

Conversation

greglucas
Copy link
Contributor

PR summary

We are getting reviewdog failures in the galleries/examples tests with numpy 2.0. There are new keyword arguments required for array and array_wrap that are expected in numpy 2.0.

From the release notes https://numpy.org/devdocs/release/2.0.0-notes.html

array_wrap is now passed arr, context, return_scalar and support for implementations not accepting all three are deprecated. Its signature should be array_wrap(self, arr, context=None, return_scalar=False)

https://numpy.org/devdocs/release/2.0.0-notes.html#the-array-special-method-now-takes-a-copy-keyword-argument

NumPy will pass copy to the array special method in situations where it would be set to a non-default value (e.g. in a call to np.asarray(some_object, copy=False)). Currently, if an unexpected keyword argument error is raised after this, NumPy will print a warning and re-try without the copy keyword argument. Implementations of objects implementing the array protocol should accept a copy keyword argument with the same meaning as when passed to numpy.array or numpy.asarray.

PR checklist

There are new keyword arguments required for __array__ and
__array_wrap__ that are expected in numpy 2.0.
@github-actions github-actions bot added the Documentation: examples files in galleries/examples label Jun 23, 2024
Copy link
Member

@story645 story645 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is probably overly complicated as a "how to make units" example, but also thanks for fixing this.

Can merge on tests passing.

@rcomer rcomer merged commit e243b2c into matplotlib:main Jun 24, 2024
25 checks passed
@rcomer rcomer added this to the v3.9.1 milestone Jun 24, 2024
@rcomer
Copy link
Member

rcomer commented Jun 24, 2024

@meeseeksdev backport to v3.9.x

meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Jun 24, 2024
rcomer added a commit that referenced this pull request Jun 24, 2024
…441-on-v3.9.x

Backport PR #28441 on branch v3.9.x (MNT: Update basic units example to work with numpy 2.0)
@greglucas greglucas deleted the np2-fix-units branch June 24, 2024 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation: examples files in galleries/examples Maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants