spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.22k stars 1.59k forks source link

Keys not displayed for a dict with float keys #19503

Open trixxx3 opened 2 years ago

trixxx3 commented 2 years ago

Description

What steps will reproduce the problem?

Problem was caused by trying to reset a key name in the popup window of a dict in the variable explorer.

Cause: Creating a dict usually with a float number as a key is allowed. So i did. create a list with floats as keys and created a dict like:

Temps = [np.float64(1), np.float64(2)]
dummy = {}
for T in Temps:
    dummy[T] = {}

The code does work but the key is not showing up in pop up window after doubble clicking dummy in the variable explorer, even though it is shown in the explorer and is callable as usual.

Ater trying some things i found out that the problem was the float64 type of my listmembers. So a fix was

for T in Temps:
    dummy[float(T)] = {}

Traceback

Traceback (most recent call last):
  File "C:\Users\Wolfram\.conda\envs\wrinkle\lib\site-packages\spyder\widgets\collectionseditor.py", line 967, in rename_item
    self.copy_item(erase_original=True, new_name=new_name)
  File "C:\Users\Wolfram\.conda\envs\wrinkle\lib\site-packages\spyder\widgets\collectionseditor.py", line 949, in copy_item
    new_key, valid = QInputDialog.getText(self, title, field_text,
TypeError: getText(QWidget, str, str, echo: QLineEdit.EchoMode = QLineEdit.Normal, text: str = '', flags: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags(), inputMethodHints: Union[Qt.InputMethodHints, Qt.InputMethodHint] = Qt.ImhNone): argument 5 has unexpected type 'numpy.float64'

Versions

Dependencies

# Mandatory:
atomicwrites >=1.2.0          :  1.4.0 (OK)
chardet >=2.0.0               :  4.0.0 (OK)
cloudpickle >=0.5.0           :  2.0.0 (OK)
cookiecutter >=1.6.0          :  1.7.3 (OK)
diff_match_patch >=20181111   :  20200713 (OK)
intervaltree >=3.0.2          :  3.0.2 (OK)
IPython >=7.6.0;<8.0.0        :  7.31.1 (OK)
jedi >=0.17.2;<0.19.0         :  0.18.1 (OK)
jellyfish >=0.7               :  0.9.0 (OK)
jsonschema >=3.2.0            :  4.4.0 (OK)
keyring >=17.0.0              :  21.2.1 (OK)
nbconvert >=4.0               :  6.4.1 (OK)
numpydoc >=0.6.0              :  1.2 (OK)
paramiko >=2.4.0              :  2.9.2 (OK)
parso >=0.7.0;<0.9.0          :  0.8.3 (OK)
pexpect >=4.4.0               :  4.8.0 (OK)
pickleshare >=0.4             :  0.7.5 (OK)
psutil >=5.3                  :  5.9.0 (OK)
pygments >=2.0                :  2.11.2 (OK)
pylint >=2.5.0                :  2.12.2 (OK)
pyls_spyder >=0.4.0           :  0.4.0 (OK)
pylsp >=1.3.2;<1.4.0          :  1.3.3 (OK)
pylsp_black >=1.0.0           :  1.1.0 (OK)
qdarkstyle =3.0.2             :  3.0.2 (OK)
qstylizer >=0.1.10            :  0.2.1 (OK)
qtawesome >=1.0.2             :  1.1.1 (OK)
qtconsole >=5.2.1;<5.3.0      :  5.2.2 (OK)
qtpy >=1.5.0                  :  2.0.0 (OK)
rtree >=0.9.7                 :  0.9.7 (OK)
setuptools >=49.6.0           :  60.6.0 (OK)
sphinx >=0.6.6                :  3.5.4 (OK)
spyder_kernels >=2.2.1;<2.3.0 :  2.2.1 (OK)
textdistance >=4.2.0          :  4.2.2 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3             :  2.1.6 (OK)
zmq >=17                      :  22.3.0 (OK)

# Optional:
cython >=0.21                 :  None (NOK)
matplotlib >=2.0.0            :  3.5.1 (OK)
numpy >=1.7                   :  1.22.1 (OK)
pandas >=1.1.1                :  1.4.0 (OK)
scipy >=0.17.0                :  1.7.3 (OK)
sympy >=0.7.3                 :  None (NOK)
ccordoba12 commented 2 years ago

Hey @trixxx3, thanks for reporting. I can reproduce the error that the dictionary keys are not displayed in our dict viewer for floats or numpy floats.

The other error (trying to rename a float key) is fixed in our latest version (5.3.3). You can update to it by closing Spyder, opening the Anaconda Prompt and running there

conda update anaconda
conda install spyder=5.3.3