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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpy 2 compatibility #345

Closed
MuellerSeb opened this issue Apr 8, 2024 · 0 comments 路 Fixed by #340
Closed

Numpy 2 compatibility #345

MuellerSeb opened this issue Apr 8, 2024 · 0 comments 路 Fixed by #340
Assignees
Labels
CI/CD enhancement New feature or request external problem FutureWarning Aim is to prevent FutureWarnings when they appear.
Milestone

Comments

@MuellerSeb
Copy link
Member

Numpy 2.0.0rc1 was released: https://pypi.org/project/numpy/2.0.0c1 and is officially usable to build extensions.
We should be prepared to be compatible with it.

  • Building with numpy 2.0.0rc1 works 馃帀
  • Running tests with numpy 2 fails 馃槶

A lot of the tests fail because of emcee and this issue: dfm/emcee#509

Other errors come from these lines in estimator.pyx:

    cdef long[:, :] counts = np.zeros((d_max, len(bin_edges)-1), dtype=long)
    cdef long[:] counts = np.zeros(len(bin_edges)-1, dtype=long)
    cdef long[:] counts = np.zeros(k_max, dtype=long)
    cdef long[:] counts = np.zeros(k_max, dtype=long)

and raise

E   ValueError: Buffer dtype mismatch, expected 'long' but got 'long long'

This only occurs on windows and is related to this: https://numpy.org/devdocs/numpy_2_0_migration_guide.html#windows-default-integer

One other category of errors is:

If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).

np.array(..., copy=False) is used in krige/base.py, 3 times in variogram/variogram.py and 3 times in tools/geometric.py

In order to mimic the ndmin=... feature, we could replace these with e.g.:

pos = np.atleast_2d(np.asarray(pos, dtype=np.double))
@MuellerSeb MuellerSeb added enhancement New feature or request FutureWarning Aim is to prevent FutureWarnings when they appear. CI/CD external problem labels Apr 8, 2024
@MuellerSeb MuellerSeb added this to the 1.5.2 milestone Apr 8, 2024
@MuellerSeb MuellerSeb self-assigned this Apr 8, 2024
@MuellerSeb MuellerSeb linked a pull request Apr 8, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/CD enhancement New feature or request external problem FutureWarning Aim is to prevent FutureWarnings when they appear.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant