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

Updating to NumPy > 2.0 #1742

Merged
merged 3 commits into from
Sep 16, 2024
Merged

Updating to NumPy > 2.0 #1742

merged 3 commits into from
Sep 16, 2024

Conversation

pat-schmitt
Copy link
Member

In this PR, I address test failures and warnings related to NumPy > 2.0.

Two tests were failing due to a silent conversion from float to int during the fixed geometry spinup. Here's a small example illustrating the issue:

test_array = np.array([1, 2, 3])
test_nr = np.float64(1.2)
test_array[0] = test_nr
print(test_array)

will print array([1, 2, 3]), whereas

test_array = np.array([1., 2., 3.])
test_nr = np.float64(1.2)
test_array[0] = test_nr
print(test_array)

will print array([1.2, 2. , 3. ]).

This behaviour is tricky to catch and highlights the importance of being mindful of the dtype when working with NumPy > 2.0.

Most of the warnings I fixed are related to xarray (likely to be resolved in future updates to xarray), and there are still some warnings from pandas that need to be addressed within pandas itself.

  • Tests added/passed
  • Fully documented
  • Entry in whats-new.rst

@pep8speaks
Copy link

pep8speaks commented Sep 10, 2024

Hello @pat-schmitt! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-09-10 18:13:37 UTC

@fmaussion fmaussion merged commit 5d87481 into OGGM:master Sep 16, 2024
27 checks passed
@fmaussion
Copy link
Member

Thanks!

@pat-schmitt pat-schmitt deleted the update_numpy branch September 23, 2024 10:54
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