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

Avoid trapz DeprecationWarning on numpy 2 #1971

Merged
merged 1 commit into from
May 12, 2024

Conversation

dopplershift
Copy link
Contributor

I haven't exhaustively gone through the changes in numpy 2, but this is enough to allow MetPy's test suite to pass with no new warnings on numpy 2.

  • Closes # (insert issue number)
  • Executed pre-commit run --all-files with no errors
  • The change is fully covered by automated unit tests
  • Documented in docs/ as appropriate
  • Added an entry to the CHANGES file

@keewis
Copy link
Contributor

keewis commented Apr 26, 2024

I thought it was cumproduct, not cumprod, that was removed?

@dopplershift
Copy link
Contributor Author

I thought it was cumproduct, not cumprod, that was removed?

Apparently, yes, it was actually just that one and apparently you got that in #1954. This is what I get for starting this from an install of pint 0.24. I'll drop that commit and that will leave only avoiding the deprecation warning if we want.

@dopplershift dopplershift changed the title Numpy 2 compatibility Avoid trapz DeprecationWarning on numpy 2 Apr 26, 2024
@keewis
Copy link
Contributor

keewis commented Apr 29, 2024

if you're fine with making this a general "numpy>=2 compat" PR, there's also the ptp method that got removed.

The implementation itself forwards to numpy.ndarray's methods, so nothing else is necessary, but the method test should be skipped if numpy>=2 is installed.

trapz has been deprecated in favor of the newly available trapezoid
function. This wraps the new function and avoids a DeprecationWarning on
numpy>=2.
@dopplershift
Copy link
Contributor Author

@keewis I'm ok with doing that, except that skipping the tests should probably go with adding Numpy 2 to the CI matrix, and I really have no clue how best to do that, unless it's a specific include on the workflow? If so, what should the other options be?

@keewis
Copy link
Contributor

keewis commented May 2, 2024

I believe you can add the release candidate to the build matrix:

include:
  # numpy>=2
  - python-version: "3.12"
    numpy: "numpy>=2.0.0rc1"
    uncertainties: null

(not sure, though)

@andrewgsavage
Copy link
Collaborator

andrewgsavage commented May 12, 2024

only 4 failures before this PR, so I'll merge this and finish it up in #1985

@andrewgsavage andrewgsavage merged commit feaa945 into hgrecco:master May 12, 2024
31 of 33 checks passed
@dopplershift dopplershift deleted the numpy2 branch May 13, 2024 16:23
takluyver pushed a commit to takluyver/pint that referenced this pull request Jun 18, 2024
trapz has been deprecated in favor of the newly available trapezoid
function. This wraps the new function and avoids a DeprecationWarning on
numpy>=2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants