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 #2153

Closed
5 tasks done
wpbonelli opened this issue Apr 15, 2024 · 4 comments · Fixed by #2241
Closed
5 tasks done

NumPy 2.0 compatibility #2153

wpbonelli opened this issue Apr 15, 2024 · 4 comments · Fixed by #2241
Milestone

Comments

@wpbonelli
Copy link
Member

wpbonelli commented Apr 15, 2024

Opening this (somewhat belatedly) to track support for NumPy 2.0, due out soon. The maintainers recommend downstream projects make a compatible release before 2.0 drops. We have already made some progress updating API usages. The biggest consideration is our runtime dependencies on projects which depend on numpy (checks indicate whether the project has released 2.0 support)

Core requirements (pandas and mpl) are already covered. If 2.0 is imminent before all our optional dependencies support it, we will need to decide whether to release immediately or wait, but it sounds like at least a month remaining, so with luck it won't come to that.

Tasks:

@wpbonelli wpbonelli added this to the 3.7.0 milestone Apr 15, 2024
@wpbonelli
Copy link
Member Author

Per the latest announcement numpy 2.0 will come out in 3.5 weeks. Flopy 3.7 is planned tomorrow to coincide with MF6.5.0, but optional dependencies have not all released np2 support. I see two paths:

  • Release numpy2 support with 3.7.0, and warn that optional dependencies are not guaranteed to be compatible yet. Installs will work fine for the core flopy package, but may break for the optional dependencies if the user has np2+, as will features using them (e.g. netcdf export).
  • Keep numpy pinned <2 for 3.7.0, and plan to release numpy2 support with 3.7.1+ in the next few weeks, if/when netcdf4-python does. Installs will continue to work in the meantime, but we may end up here again if a netcdf release is not forthcoming, in which case I'm not sure anything further can be done to avoid potential breakage

@jdhughes-usgs
Copy link
Contributor

@wpbonelli I think we should pin to <2 for 3.7.0 and do another release later

@wpbonelli wpbonelli modified the milestones: 3.7.0, 3.7.1 May 23, 2024
@wpbonelli
Copy link
Member Author

wpbonelli commented Jun 16, 2024

NumPy 2.0 came out today.

Netcdf4-python has made a numpy2-compatible release (1.7.0) but there are some issues with the package. Seems like they are working on a fix, after which I think we can proceed at any time.

Should we make a new release promptly? We have a number of bugfixes and a couple new features since 3.7.0. I guess np2 support could also be considered a feature, so by semver this would be 3.8.0. If others agree I can remove the pin and get the ball rolling when netcdf4 is ready.

wpbonelli pushed a commit that referenced this issue Jun 17, 2024
Checking test_uzf_negative_iuzfopt with NumPy 2.0 (xref #2153), this test failed. The test criteria originally had several issues, including confusing extpd as pet. These issues are fixed in this PR to properly compare expected array values.
wpbonelli pushed a commit that referenced this issue Jun 17, 2024
…20.3 (#2237)

This PR resolves several deprecation warnings from NumPy 2.0 (xref #2153):

* np.in1d() → np.isin()
* "a16" → "S16" to describe 16-length string of bytes
* The numpy.core.records module is private, so use numpy.rec instead, which seems to work with older versions

This also bumps the minimum version of numpy from 1.15.0 to 1.20.3, since this is the minimum for pandas 2.0.0, thus the minimum versions were incompatible.
@langevin-usgs
Copy link
Contributor

NumPy 2.0 came out today.

Netcdf4-python has made a numpy2-compatible release (1.7.0) but there are some issues with the package. Seems like they are working on a fix, after which I think we can proceed at any time.

Should we make a new release promptly? We have a number of bugfixes and a couple new features since 3.7.0. I guess np2 support could also be considered a feature, so by semver this would be 3.8.0. If others agree I can remove the pin and get the ball rolling when netcdf4 is ready.

I like the idea of making a new release that supports numpy 2.0. We will likely have others as this all settles in, but my opinion is to keep moving it forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants