sharppy / SHARPpy

Sounding/Hodograph Analysis and Research Program in Python
https://sharppy.github.io/SHARPpy/index.html
Other
216 stars 112 forks source link

[BUG] Preferences window fails to open #224

Closed skovic closed 1 year ago

skovic commented 2 years ago

After clicking on Files->Preferences, the Preferences window fails to open, and the following error appears in the .sharppy/sharppy-out.txt file:

TypeError: only integer scalar arrays can be converted to a scalar index
Traceback (most recent call last):
  File "full_gui.py", line 1045, in preferencesbox
  File "sharppy\viz\preferences.py", line 344, in __init__
  File "sharppy\viz\preferences.py", line 378, in __initUI
  File "sharppy\viz\preferences.py", line 407, in _createReadoutWidget
OverflowError

This problem occurs while running the latest code from the master branch. I ran into this problem using a Windows binary (in Windows 10) that I built and also by running SHARPpy.py in a Linux environment. In both environments, I am using miniconda with the latest conda packages installed. The versions of the packages of interest are:

numpy 1.21.4 qt 5.12.9 qtpy 1.11.2

Root Cause: Only an argument for the condition parameter is being provided when where() is called. As a result, per the numpy docs, this function call is actually shorthand for np.asarray(condition).nonzero(). Therefore, a tuple of arrays is actually being returned with one array per dimension, containing the indices of non-zero elements. For this reason, accessing the first element of each tuple actually yields an array of indices. This array (ndarray) of indices is then passed to setCurrentIndex() which is expecting an integer to be passed, resulting in the observed error.

c0r3dump3d commented 1 year ago

Hi, I have the same issue in sharppy 1.4.0 conda installation (conda 4.12.0), in a Linux Manjaro:

TypeError: only integer scalar arrays can be converted to a scalar index
Traceback (most recent call last):
  File "/home/andrew/anaconda3/envs/sharppy-env/lib/python3.9/site-packages/runsharp/full_gui.py", line 1045, in preferencesbox
    pref_dialog = PrefDialog(self.config, parent=self)
  File "/home/andrew/anaconda3/envs/sharppy-env/lib/python3.9/site-packages/sharppy/viz/preferences.py", line 344, in __init__
    self.__initUI()
  File "/home/andrew/anaconda3/envs/sharppy-env/lib/python3.9/site-packages/sharppy/viz/preferences.py", line 378, in __initUI
    readout_widget = self._createReadoutWidget()
  File "/home/andrew/anaconda3/envs/sharppy-env/lib/python3.9/site-packages/sharppy/viz/preferences.py", line 407, in _createReadoutWidget
    self.combo1.setCurrentIndex(idx1)
OverflowError
Jeff-Szkodzinski commented 1 year ago

The fix for this has been merged into the 'main' branch.