FXIhub / hummingbird

Monitoring and Analysing flash X-ray imaging experiments
http://fxihub.github.io/hummingbird
BSD 2-Clause "Simplified" License
16 stars 14 forks source link

numpy 2.x compatibility #153

Closed egorsobolev closed 4 months ago

egorsobolev commented 4 months ago

This fixes an exception on image replot:

Traceback (most recent call last):
  File "/home/spbop/hummingbird/hummingbird/interface/gui.py", line 223, in _replot
    p.replot()
  File "/home/spbop/hummingbird/hummingbird/interface/ui/image_window.py", line 467, in replot
    img = numpy.array(pd_y, copy=False)
ValueError: Unable to avoid copy while creating an array as requested.
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).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.
codecov-commenter commented 4 months ago

Codecov Report

Attention: Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.

Project coverage is 22.55%. Comparing base (92f8772) to head (4346b34).

Files Patch % Lines
hummingbird/interface/ui/plot_window.py 0.00% 8 Missing :warning:
hummingbird/interface/ui/image_window.py 0.00% 5 Missing :warning:
hummingbird/interface/data_source.py 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #153 +/- ## ========================================== + Coverage 22.52% 22.55% +0.02% ========================================== Files 89 89 Lines 7502 7501 -1 ========================================== + Hits 1690 1692 +2 + Misses 5812 5809 -3 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

egorsobolev commented 4 months ago

numpy 2.0 starts to raise ValueError on numpy.array(..., copy=False) if the array cannot be created without copying data. In previous versions, the data would not copy only if that possible, and array was creating in any case. The same behavior has the call numpy.asarray(...) in both new and old versions of numpy.