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

Add support for numpy v2 #179

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Add support for numpy v2 #179

wants to merge 4 commits into from

Conversation

dihm
Copy link
Contributor

@dihm dihm commented Aug 14, 2024

This PR should provide the required changes for ARC to build against numpy v2 (which provides backwards compatibility for v1.x at runtime). Exception is for python 3.8, which does not appear to have numpy v2 support. I have explicitly confirmed that local installations function for numpy==2.0 and numpy==1.23 under python=3.11.

As far as source code changes, ARC only required a single function change due to the re-naming of np.trapz to np.trapezoid. Unfortunately, supporting that name change would require a runtime check based on the numpy version. As a simpler choice, I moved those calls to scipy.integrate.trapezoid which should be completely equivalent.

Fixes #178 (and other similar questions)

References:

Numpy 2.0 migration guide
Depending on numpy - 2.0 advice
SciPy Developer Advice for NumPy

Numpy v2.0.0 contains backwards ABI compatibility machinery to work with
numpy v1.xx at runtime (possibly as far back at v1.19)
This version is guaranteed to work with numpy v2 ABI builds.
While we could use the new name numpy.trapezoid,
it would require runtime checks on numpy version to select the correct
name when using numpy v1 or v2.

Instead replace with scipy.integrate.trapezoid since we depend on scipy
already and is an equivalent function.
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.

ImportError: numpy.core.multiarray failed to import
1 participant