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

Fixes for NumPy 2.0 compatiblity #422

Merged
merged 3 commits into from
Sep 26, 2023

Conversation

WilliamJamieson
Copy link
Contributor

NumPy 2.0 has removed a couple of type aliases referenced by deepdiff as part of NEP 52 in numpy/numpy#24376. Namely,

  • np.float_, which is an alias of np.double according to the NumPy docs.
  • np.complex_, which is an alias of np.cdouble according to the NumPy docs.

These are blocking my ability to test code using NumPy 2.0 (see spacetelescope/romancal#886).

When I ran the test suite with NumPy 2.0 installed there was one additional deprecation of np.in1d in favor or np.isin.

In any case, the deepdiff tests pass locally for me if I install the published dev wheel of NumPy via:

pip install --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple "numpy>=0.0.dev0

to override the current requirements-dev.txt pin for NumPy. I have not touched the GitHub CI for deepdiff in order to run NumPy 2.0 tests at this time, please let me know if/how you would like me to do this if you would like that added.

@seperman
Copy link
Owner

Hi @WilliamJamieson
Thanks for the PR. We should bump the Numpy version in requirements-dev.txt to Numpy 2.0
We should still run the test suite with numpy==1.24.4 as well to ensure we have backward compatibility. That can be achieved by modifying the matrix section in GitHub actions in .github/workflows/main.yaml. We should add The 2 different Numpy versions there and cache pip for each one of these configurations. What do you think?

@WilliamJamieson
Copy link
Contributor Author

Since NumPy 2.0 is still in development you probably do not want to cache it because you will need to pull the nightly wheel.

Comment on lines +18 to +23
- python-version: 3.9
numpy-version: "2.0.dev"
- python-version: 3.10
numpy-version: "2.0.dev"
- python-version: 3.11
numpy-version: "2.0.dev"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per NEP 29, NumPy is only supported on Python 3.9+.

@seperman
Copy link
Owner

LGTM!

@codecov-commenter
Copy link

Codecov Report

Merging #422 (c9232d2) into dev (2f62074) will increase coverage by 0.03%.
The diff coverage is 100.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##              dev     #422      +/-   ##
==========================================
+ Coverage   98.60%   98.63%   +0.03%     
==========================================
  Files          14       14              
  Lines        3299     3299              
==========================================
+ Hits         3253     3254       +1     
+ Misses         46       45       -1     
Files Coverage Δ
deepdiff/helper.py 97.37% <100.00%> (+0.29%) ⬆️

@seperman seperman merged commit 4fe9f92 into seperman:dev Sep 26, 2023
5 checks passed
@WilliamJamieson WilliamJamieson deleted the bugfix/numpy2.0 branch September 27, 2023 00:50
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