LaboratoireMecaniqueLille / crappy

Command and Real-time Acquisition Parallelized in Python
https://crappy.readthedocs.io/en/stable/
GNU General Public License v2.0
78 stars 16 forks source link

Bug with numpy 2.0.0 #125

Open WeisLeDocto opened 2 months ago

WeisLeDocto commented 2 months ago

Recently, the 2.0.0 version of Numpy was released. Crappy's behavior seems to be overall unaffected by this upgrade, but a bug caused by a breaking change was already discovered.

Specifically, the numpy.max() function used to return a value with a builtin float or int type. It now returns a scalar of the same numpy type as the array on which the function is applied. When using it on images with type uint8, this means that numpy.max(x) + 1 can now take values between 0 and 255, versus 1 to 256 previously. This is the cause of a bug identified in the CameraConfig class, when an 8-bits image takes values equal to 255: https://github.com/LaboratoireMecaniqueLille/crappy/blob/e069fd4c6cf7209c56833290a24f3f4235c9684c/src/crappy/tool/camera_config/camera_config.py#L866-L868

It is unknown whether similar bugs are present elsewhere in the codebase, so the camera-related code will need to be thoroughly reviewed. I'm not favorable to restricting the compatible versions of numpy to <2.0.0, even temporarily, as this would slow down bug detection, and users can always quickly fix by downgrading to numpy 1.26. If any bugs are reported, users can be directed towards this issue.