gecos-lab / PZero

GNU Affero General Public License v3.0
22 stars 2 forks source link

crash when editing geological type #52

Closed andrea-bistacchi closed 1 year ago

andrea-bistacchi commented 1 year ago

We have a bug. When the geological type is edited in the geological collection table, PZero crashes. This used to work flawlessly.

I suspect we have a problem with a signal related to changing an entity metadata.

I'll try to figure out.

mcbaguetti commented 1 year ago

To me the first error when I modify a geol. type is:

File "c:\...\pzero\legend_manager.py", line 220, in update_widget
    geol_point_size_spn.setValue(point_size)
TypeError: setValue(self, val: int): argument 1 has unexpected type 'numpy.float64'

It seems point_size is a numpy.float64 meanwhile setValue expect an int input. I checked QSpinBox().setValue() and even in the previous qt version expected an integer. So I checked where we get point_size and it's taken by Dataframe.values[0], this method returns a numpy array and I think the issue comes from a different numpy version (some ref. here).

By the way, I discovered the issue wasn't the float64 itself but instead when we have a nan float value. In order to solve this we only need to add a check on the values could be nan:

from math import isnan
...

if isnan(point_size):
    point_size = 0
geol_point_size_spn.setValue(point_size)

In order to prevent the crash we need to add the if statement to pointsize and to opacity as well (line 220 and 227)

mcbaguetti commented 1 year ago

I pushed the solution on the env_testing branch

mcbaguetti commented 1 year ago

pushed on the main branch with this commit inside legend_manager.py