mrkrd / cochlea

Inner ear models for Python
GNU General Public License v3.0
108 stars 42 forks source link

examples/stats_tuning example does not work #6

Closed tokekark closed 6 years ago

tokekark commented 6 years ago

I have installed cochlea on Ubuntu and trying to run stats_tuning.py. This gives a strange error as follows. I havn't changed any code. ERROR STACK - Traceback (most recent call last): File "stats_tuning.py", line 41, in main() File "stats_tuning.py", line 24, in main model_pars={'species': 'human'} File "/usr/local/lib/python3.6/dist-packages/cochlea/stats/tuning.py", line 53, in calc_tuning model_pars=model_pars File "/usr/local/lib/python3.6/dist-packages/thorns/util/maps.py", line 387, in wrap result = func(*kwargs) File "/usr/local/lib/python3.6/dist-packages/cochlea/stats/threshold_rate.py", line 88, in calc_spont_threshold silence = np.zeros(fstmax) TypeError: 'float' object cannot be interpreted as an integer

mrkrd commented 6 years ago

I have installed cochlea on Ubuntu and trying to run stats_tuning.py. This gives a strange error as follows. I havn't changed any code. ERROR STACK - Traceback (most recent call last): File "stats_tuning.py", line 41, in main() File "stats_tuning.py", line 24, in main model_pars={'species': 'human'} File "/usr/local/lib/python3.6/dist-packages/cochlea/stats/tuning.py", line 53, in calc_tuning model_pars=model_pars File "/usr/local/lib/python3.6/dist-packages/thorns/util/maps.py", line 387, in wrap result = func(*kwargs) File "/usr/local/lib/python3.6/dist-packages/cochlea/stats/threshold_rate.py", line 88, in calc_spont_threshold silence = np.zeros(fstmax) TypeError: 'float' object cannot be interpreted as an integer

  1. This particular error has been fixed in the repository. I'll bump the version and upload to PyPI later this week. If you don't want to wait, you can run the version from the master.

  2. It looks that you are using Python 3.6, but cochlea was only tested on Python 2.7. You might encounter some problems with that. In this case I would recommend to use Python 2.7. Either case, I would like to know how did it go. :-)

tokekark commented 6 years ago

Yes I realized the python 3.6 related issue and made a small fix in my local code. Those worked for me very well. (Thanks for your prompt response.)

  1. cochlea/stats/threshold_rate.py - line 88
    
    (silence = np.zeros(fs*tmax)) 
    #replaced by silence = np.zeros(int(fs*tmax))

In Thorns
2. thorns/util/maps.py - attribute "'func_name" replaced with "__name__".
See if these are correct fixes (though did not check impact on rest of the code). In case you want me fix those let me know (I am new to github)
mrkrd commented 6 years ago

Thank for the feedback. I've just uploaded the most recent versions to PyPI.