microscope-cockpit / cockpit

Cockpit is a microscope graphical user interface. It is a flexible and easy to extend platform aimed at life scientists using bespoke microscopes.
https://microscope-cockpit.org
GNU General Public License v3.0
35 stars 26 forks source link

Numpy v2 has a range of API changes. #889

Open iandobbie opened 5 months ago

iandobbie commented 5 months ago

Numpy is just about to upgrade to V2. There are a large number of API changes and I have no idea if they will affect cockoit or not but we probably ought to check. Migration guide...

https://numpy.org/devdocs/numpy_2_0_migration_guide.html

I will see if I see any obvious issues but we probably have to try it.

Ian

iandobbie commented 3 months ago

Julio suggests that we pin numpy to version 1 for a few months to allow any libraries we use that depend on numpy to be updated.

carandraug commented 3 months ago

I don't understand how we pinning to numpy v1 helps the other libraries. If we don't pin, then we're declaring we work with both v1 and v2, leaving the choice of what version to be installed up to pip (and pip will install an older version if it detects that the other libraries need that older version).

juliomateoslangerak commented 3 months ago

The problem is that some key libraries (don't remember which ones) are not pinning down numpy 1 and they have not been tested with numpy 2. Not pinning down microscope to numpy 1 might lead to installation of numpy 2 and causing problems through those libraries. We should pin v1 until they fix their issues. I can check which libraries are causing the issue.

I think in general its a good practice to pin down the major versions (breaking changes) to avoid trouble.

carandraug commented 1 month ago

I just pushed 6f441e2e and 5326c4b8 which fix numpy 2 compatibility issues (there may be others though). Can someone test in actual microscope?

The problem is that some key libraries (don't remember which ones) are not pinning down numpy 1 and they have not been tested with numpy 2. Not pinning down microscope to numpy 1 might lead to installation of numpy 2 and causing problems through those libraries. We should pin v1 until they fix their issues. I can check which libraries are causing the issue.

I really don't think we should be pinning a requirement on numpy 1 for the sake of other libraries. Instead lets request the other libraries to pin it themselves.

I think in general its a good practice to pin down the major versions (breaking changes) to avoid trouble.

Pinning a requirement on an older version prevents the user from installing a newer, possible faster or less buggy version. It also prevents the user from installing other packages that may require the newer version.

Just because a newer version introduces breaking changes, it doesn't mean it will break things for us. And if we're good at keeping dependencies up to date then we can make it work with both. For example, all the fixes for numpy 2 still work with numpy 1.

iandobbie commented 1 month ago

I will try these updates on my test system with has a picamera, ludl stage and then simulated light sources but a red pitaya executor for digital and analog control. Might take a few days as I want to test with numpy 1 as it is then upgrade at least the windows pc and the py to numpy 2 and check it all still works. Not sure how easy it will be to upgrade the red pitaya numpy version.