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

Merged
merged 4 commits into from
Oct 4, 2024
Merged

Add support for numpy v2 #179

merged 4 commits into from
Oct 4, 2024

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

dihm added 4 commits August 14, 2024 13:17
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.
@nikolasibalic nikolasibalic self-requested a review October 4, 2024 14:32
@nikolasibalic nikolasibalic changed the base branch from master to draft_v3.6.0 October 4, 2024 14:33
@nikolasibalic nikolasibalic changed the base branch from draft_v3.6.0 to master October 4, 2024 14:33
@nikolasibalic nikolasibalic merged commit ece00f9 into nikolasibalic:master Oct 4, 2024
10 checks passed
@nikolasibalic nikolasibalic added this to the v3.6.0 milestone Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ImportError: numpy.core.multiarray failed to import
2 participants