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

Open
qiyunzhu opened this issue Mar 9, 2024 · 11 comments
Open

NumPy 2.0 compatibility #1964

qiyunzhu opened this issue Mar 9, 2024 · 11 comments

Comments

@qiyunzhu
Copy link
Contributor

qiyunzhu commented Mar 9, 2024

It seems that scikit-bio is compatible with the upcoming NumPy 2.0. Following this guideline, I ran:

ruff check skbio --select NPY201

And nothing happened, meaning the check passed. However, I haven't been able to actually install NumPy 2.0 for test (probably because it is still under active development). Therefore we should keep an eye on it.

Thanks @wasade for pointing out this.

@rgommers
Copy link

rgommers commented Apr 1, 2024

You can install numpy 2.0.0rc1 from PyPI now, with pip install numpy --pre. It'd be great to get a confirmation that everything works well with numpy 2.x

@qiyunzhu
Copy link
Contributor Author

qiyunzhu commented Apr 1, 2024

@rgommers Thanks for pointing us to this!

Just tested. Got error:

File "h5py/_errors.pyx", line 1, in init h5py._errors
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

This is probably an issue in h5py, a dependency of scikit-bio. I saw this discussion in the h5py codebase. We probably need to wait until after they release a NumPy 2.0 compatible version. @wasade

@rgommers
Copy link

rgommers commented Apr 2, 2024

Thanks for testing @qiyunzhu. Good to know about h5py, I've asked on the issue you linked.

@qiyunzhu
Copy link
Contributor Author

qiyunzhu commented Apr 5, 2024

@rgommers Update: I was able to install numpy 2.0.0rc1 and compatible versions of scipy, pandas and h5py. Then got the following error when importing scikit-bio:

  File "skbio/stats/__subsample.pyx", line 1, in init skbio.stats.__subsample
ImportError: numpy.core.multiarray failed to import (auto-generated because you didn't call 'numpy.import_array()' after cimporting numpy; use '<void>numpy._import_array' to disable if you are certain you don't need it).

We have planned to replace the __subsample function with a new one so this error might become irrelevant in the next release. But if you have some insights to share we will appreciate.

@rgommers
Copy link

rgommers commented Apr 5, 2024

Not too much more than what the error message says:

because you didn't call 'numpy.import_array()' after cimporting numpy

in the Cython file where this error comes from, I assume there's a cimport numpy as cnp statement. and no cnp.import_array().

@rgommers
Copy link

h5py release is out now - slowly getting there:)

@qiyunzhu
Copy link
Contributor Author

Thanks for the update! Now we are waiting for Pandas 2.2.2. Then we add numpy 2.0 support for the upstream package biom-format. Then we can unblock numpy 2.0 in scikit-bio.

@rgommers
Copy link

Now we are waiting for Pandas 2.2.2.

That's up on PyPI too now, since ~25 minutes ago.

@rgommers
Copy link

rgommers commented May 8, 2024

Hi @qiyunzhu, I just wanted to check in on this, and ask if you plan to include support in 0.6.1 or 0.7.0 (and, if you know, roughly when)?

@qiyunzhu
Copy link
Contributor Author

qiyunzhu commented May 8, 2024

Hello @rgommers , We recently resolved the NumPy 2.0 support issue in the upstream package biom-format (see here). We are about to resolve this in scikit-bio in the next few days. It will be 0.6.1. Let's say it will be released in a month or so.

@rgommers
Copy link

rgommers commented May 8, 2024

Thanks! I'm not 100% sure that the final numpy 2.0 release will take more than a month from now, so a release before the end of May would be safer. But if you've got all the problems resolved then that's already good to know.

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

No branches or pull requests

2 participants