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.0 compatibility #691

Open
jhkennedy opened this issue Dec 24, 2024 · 0 comments
Open

Numpy 2.0 compatibility #691

jhkennedy opened this issue Dec 24, 2024 · 0 comments
Labels
cleanup dependencies Pull requests that update a dependency file

Comments

@jhkennedy
Copy link
Collaborator

Prompted by conda-forge/raider-feedstock#19 , I followed the Numpy 2.0 migration guide I ran:

ruff check path/to/code/ --select NPY201

which reported some incompatibilities that should be fixed:

$ ruff check . --select NPY201
test/test_integration.py:16:33: NPY201 `np.trapz` will be removed in NumPy 2.0. Use `numpy.trapezoid` on NumPy 2.0, or ignore this warning on earlier versions.
   |
14 |     for level in range(y.shape[2]):
15 |         assert np.allclose(
16 |             np.apply_along_axis(np.trapz, 2, y[..., level:], x=x[level:]),
   |                                 ^^^^^^^^ NPY201
17 |             np.trapz(y[..., level:], x[level:], axis=2)
18 |         )
   |
   = help: Replace with `numpy.trapezoid` (requires NumPy 2.0 or greater)

test/test_integration.py:17:13: NPY201 `np.trapz` will be removed in NumPy 2.0. Use `numpy.trapezoid` on NumPy 2.0, or ignore this warning on earlier versions.
   |
15 |         assert np.allclose(
16 |             np.apply_along_axis(np.trapz, 2, y[..., level:], x=x[level:]),
17 |             np.trapz(y[..., level:], x[level:], axis=2)
   |             ^^^^^^^^ NPY201
18 |         )
   |
   = help: Replace with `numpy.trapezoid` (requires NumPy 2.0 or greater)

test/test_integration.py:30:33: NPY201 `np.trapz` will be removed in NumPy 2.0. Use `numpy.trapezoid` on NumPy 2.0, or ignore this warning on earlier versions.
   |
28 |     for level in range(y.shape[2]):
29 |         assert np.allclose(
30 |             np.apply_along_axis(np.trapz, 2, y[..., level:], x=x[level:]),
   |                                 ^^^^^^^^ NPY201
31 |             np.trapz(y[..., level:], x[level:], axis=2)
32 |         )
   |
   = help: Replace with `numpy.trapezoid` (requires NumPy 2.0 or greater)

test/test_integration.py:31:13: NPY201 `np.trapz` will be removed in NumPy 2.0. Use `numpy.trapezoid` on NumPy 2.0, or ignore this warning on earlier versions.
   |
29 |         assert np.allclose(
30 |             np.apply_along_axis(np.trapz, 2, y[..., level:], x=x[level:]),
31 |             np.trapz(y[..., level:], x[level:], axis=2)
   |             ^^^^^^^^ NPY201
32 |         )
   |
   = help: Replace with `numpy.trapezoid` (requires NumPy 2.0 or greater)

test/test_integration.py:41:33: NPY201 `np.trapz` will be removed in NumPy 2.0. Use `numpy.trapezoid` on NumPy 2.0, or ignore this warning on earlier versions.
   |
39 |     for level in range(y.shape[2]):
40 |         assert np.allclose(
41 |             np.apply_along_axis(np.trapz, 2, y[..., level:], x=x[level:]),
   |                                 ^^^^^^^^ NPY201
42 |             np.trapz(y[..., level:], x[level:], axis=2)
43 |         )
   |
   = help: Replace with `numpy.trapezoid` (requires NumPy 2.0 or greater)

test/test_integration.py:42:13: NPY201 `np.trapz` will be removed in NumPy 2.0. Use `numpy.trapezoid` on NumPy 2.0, or ignore this warning on earlier versions.
   |
40 |         assert np.allclose(
41 |             np.apply_along_axis(np.trapz, 2, y[..., level:], x=x[level:]),
42 |             np.trapz(y[..., level:], x[level:], axis=2)
   |             ^^^^^^^^ NPY201
43 |         )
   |
   = help: Replace with `numpy.trapezoid` (requires NumPy 2.0 or greater)

tools/RAiDER/models/weatherModel.py:445:44: NPY201 `np.trapz` will be removed in NumPy 2.0. Use `numpy.trapezoid` on NumPy 2.0, or ignore this warning on earlier versions.
    |
443 |         wet_total, hydro_total = np.zeros(wet.shape), np.zeros(hydro.shape)
444 |         for level in range(wet.shape[2]):
445 |             wet_total[..., level] = 1e-6 * np.trapz(
    |                                            ^^^^^^^^ NPY201
446 |                 wet[..., level:], x=self._zs[level:], axis=2
447 |             )
    |
    = help: Replace with `numpy.trapezoid` (requires NumPy 2.0 or greater)

tools/RAiDER/models/weatherModel.py:448:46: NPY201 `np.trapz` will be removed in NumPy 2.0. Use `numpy.trapezoid` on NumPy 2.0, or ignore this warning on earlier versions.
    |
446 |                 wet[..., level:], x=self._zs[level:], axis=2
447 |             )
448 |             hydro_total[..., level] = 1e-6 * np.trapz(
    |                                              ^^^^^^^^ NPY201
449 |                 hydro[..., level:], x=self._zs[level:], axis=2
450 |             )
    |
    = help: Replace with `numpy.trapezoid` (requires NumPy 2.0 or greater)

Found 8 errors.
No fixes available (8 hidden fixes can be enabled with the `--unsafe-fixes` option).
@jlmaurer jlmaurer added cleanup dependencies Pull requests that update a dependency file labels Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

2 participants