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

Support numpy 2.0 #3033

Open
h-mayorquin opened this issue Jun 17, 2024 · 15 comments
Open

Support numpy 2.0 #3033

h-mayorquin opened this issue Jun 17, 2024 · 15 comments
Labels
packaging Related to packaging/style

Comments

@h-mayorquin
Copy link
Collaborator

h-mayorquin commented Jun 17, 2024

We are not able -and it is not probably a good idea- to support numpy 2.0 as soon as possible.

The ecocsystem will take some time to adapt and we should wait some time until most libraries that use and interact with spikeinterface support numpy 2.0 so we don't create problems for them.

We should though start deprecating functions and removing things that are not supported by 2.0 when that is possible. The PR #3032 takes some steps in that direction.

One big roadblock is that some libraries used heavily by this package require lower bounds on their versions for supporting numpy 2.0. Here they are:

numba 0.60.0 (with caveats, see)
h5py 3.11
hdmf-zarr 0.7.0
scipy release 1.13
pandas 2.2.2

pynwb and hdmf-zarr don't support numpy 2.0 yet. So we can't install them if we install numpy 2.0

We can keep this an open issue discuss how, when and related issues.

@h-mayorquin h-mayorquin added the packaging Related to packaging/style label Jun 17, 2024
@h-mayorquin
Copy link
Collaborator Author

We will need to review of copy as that API is changing:

https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword

@h-mayorquin
Copy link
Collaborator Author

In #3032 I set the minimal version numpy maybe a little bit too high. The reason is that pickled files before that version won't open in numpy 2.0 in the future:

https://numpy.org/doc/stable/numpy_2_0_migration_guide.html#note-about-pickled-files

And I know that @samuelgarcia cares about that.

@h-mayorquin
Copy link
Collaborator Author

Other possible improvements once we bump to numpy 2.0:

They say they also make the sorting faster for numpy in 2.0. I am looking forward to test the sorting generation functions which use this feature.

@zm711
Copy link
Collaborator

zm711 commented Jun 18, 2024

Here is the quantities NumPy 2.0 compatibility PR. python-quantities/python-quantities#232

@samuelgarcia
Copy link
Member

In #3032 I set the minimal version numpy maybe a little bit too high. The reason is that pickled files before that version won't open in numpy 2.0 in the future:

https://numpy.org/doc/stable/numpy_2_0_migration_guide.html#note-about-pickled-files

And I know that @samuelgarcia cares about that.

Normally we are not saving numpy arrays with object in np.save() so normally the pickled by numpy should not happen.
But some zarr stuff could be pickled under the wood we need to check.

@h-mayorquin
Copy link
Collaborator Author

@samuelgarcia

Would you rather relax the bound to the introduction of np.ptp which we need?

@samuelgarcia
Copy link
Member

Would you rather relax the bound to the introduction of np.ptp which we need?

No sure to understand this.
np.ptp disappear in numpy 2. ? or was introduced recently ?

@h-mayorquin
Copy link
Collaborator Author

The second, it was introduced in 1.20 so that would need to lower bound if we are not concerned about future pickability.

@samuelgarcia
Copy link
Member

OK I understand now.
My intuition would go for numpy1.20.
1.26 looks very very young.

I do not think that we have numpy.save() that do pickle internally. maybe I am wrong.
the np.save is mainly for extension and spike vector saving no ? so standard comptact dtype. Am i wrong ?

@h-mayorquin
Copy link
Collaborator Author

h-mayorquin commented Jun 20, 2024

I also feel that we should for 1.20.

Let me do a brief search to see if we are pickling somewhere as a save. We should relax numpy before the next release.

Let me open a PR and tag it so we don't forget : P

@cwindolf
Copy link
Collaborator

cwindolf commented Jan 2, 2025

Seems pynwb, hdmf-zarr, quantities, and neo support numpy 2 now. Are there other dependencies blocking numpy 2.0 in spikeinterface?

@h-mayorquin
Copy link
Collaborator Author

Need to modify this PR to relax higher version on pyproject toml and see that everything works in the CI.
#3481

Thanks for the reminder.

@samuelgarcia
Copy link
Member

Seems pynwb, hdmf-zarr, quantities, and neo support numpy 2 now. Are there other dependencies blocking numpy 2.0 in spikeinterface?

No sure neo is totally yet numpy2 but almost.

@zm711
Copy link
Collaborator

zm711 commented Jan 8, 2025

Neo just needs blackrock to support numpy 2.0 and then we are fully ready. Core Neo is compliant, but we have one last IO to do and then we are fully ready for 2.0. But blackrock rawio does name mangling so I hate working on it :(

@samuelgarcia
Copy link
Member

I can take the blackrock.

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

No branches or pull requests

4 participants