psychopy / psychopy

For running psychology and neuroscience experiments
http://www.psychopy.org
GNU General Public License v3.0
1.68k stars 907 forks source link

Error when saving data from the `gammaMotionNull` demo #2832

Open mdcutone opened 4 years ago

mdcutone commented 4 years ago

When saving the data from the gammaMotionNull demo I encounter this error:

Traceback (most recent call last):
  File "C:\Users\lab\PycharmProjects\psychopy\psychopy\demos\coder\experiment control\gammaMotionNull.py", line 165, in <module>
    stairCases[1].saveAsText(fileName + 'hi')
  File "C:\Users\lab\PycharmProjects\psychopy\psychopy\data\staircase.py", line 468, in saveAsText
    reversalStr = str(self.reversalIntensities)
TypeError: 'float' object cannot be interpreted as an integer

This is from PsychoPy version 2020.1.3 running on Win10.

peircej commented 4 years ago

That's a really weird one. I can't replicate it. Probably this is to do with a numpy version (it recently got more strict on indexes not being floats)

BUT the error stack doesn't point to a line where an integer should be needed at all. I wonder if the error trace is pointing to the right version of PsychoPy :-/

chkoss commented 3 years ago

I encountered the same error (PsychoPy3, version 2021.1.4 running on macOS Catalina).

To figure out what's going on, I put the following lines into staircase.py right before the line where the error is thrown:

for i, rev in enumerate(self.reversalIntensities):
    print(rev)
    print(type(rev))
    print(str(rev))

Re-running gammaMotionNull then gives the following output:

0.30000000000000004
<class 'float'>
Traceback (most recent call last):
  File "/Users/christina/opt/anaconda3/envs/sig_det_exp/lib/python3.6/site-packages/psychopy/demos/coder/experiment control/gammaMotionNull.py", line 165, in <module>
    stairCases[1].saveAsText(fileName + 'hi')
  File "/Users/christina/opt/anaconda3/envs/sig_det_exp/lib/python3.6/site-packages/psychopy/data/staircase.py", line 475, in saveAsText
    print(str(rev))
TypeError: cannot convert 'float' object to bytes

So when checking the type it seems to be a float, which should be convertible to a string using str(). But then it cannot be converted ... Any ideas what could cause this?