AOtools / soapy

A Python Adaptive Optics Simulation
GNU General Public License v3.0
85 stars 32 forks source link

incompatibility with numpy version > 2.0 #143

Open ricogendron opened 1 week ago

ricogendron commented 1 week ago

Recent numpy version >2.0 has a different behaviour compared to older ones, illustrated below.

With a recent numpy version:

In [4]: numpy.__version__
Out[4]: '2.0.2'

In [5]: numpy.any(None) != None
Out[5]: True

With older one:

In [11]: numpy.__version__
Out[11]: '1.21.5'

In [12]: numpy.any(None) != None
Out[12]: False

This change makes the soapy gui to crash, because of the many lines in soapy/soapy/gui/gui.py of this type :

   if numpy.any(plotDict["wfsFocalPlane"][wfs])!=None:

because now the code attempts to plot None in the graphics windows!

The issue can be solved by using instead this syntax below (as well as for 8 others similar lines in the functions update() and getPlotScaling() of gui.py) :

   if plotDict["wfsFocalPlane"][wfs] is not None:

This change will in turn preserve the compatibility with all numpy versions, older or recent.