astro4dev / OAD-Data-Science-Toolkit

The Office of Astronomy for Development's Data Science Toolkit.
https://datascience.astro4dev.org
GNU General Public License v3.0
20 stars 21 forks source link

Bug in the GMM_Python.ipynb notebook. #15

Closed astro4dev closed 7 years ago

astro4dev commented 7 years ago

Running the code below:

plt.figure(figsize=(14,6))

ax1 = plt.subplot(121)
for i in enumerate(['C0','C3']):
    plot_BPT_ell(gmm2.covariances_[i[0]], gmm2.means_[i[0]], ax=ax1, col=i[1])

ax2 = plt.subplot(122)
for i in enumerate(['C0','C3']):
    plot_WHAN_ell(gmm2.covariances_[i[0]], gmm2.means_[i[0]], ax=ax2, col=i[1])

%run fig_config.py

I get:

ValueError: could not convert string to float: 'c0'

I have merged the error to the master branch so you can view the entire error.

pylablanche commented 7 years ago

Which version of python and matplotlib are you using?

astro4dev commented 7 years ago
$ python
Python 2.7.9 (default, Jun 29 2016, 13:08:31) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print (sys.version)
2.7.9 (default, Jun 29 2016, 13:08:31) 
[GCC 4.9.2]
>>> import matplotlib
>>> matplotlib.__version__
'1.4.2'

So Python 2.7.9 and matplotlib 1.4.2.

paultheastronomer commented 7 years ago

I will be changing to my own profile.

pylablanche commented 7 years ago

The notebook is indeed written in python 3. Try to run it in python3 and let me know if it still doesn't work. Including the mention "python3 compatible" sounds sensible. I can try to make a python2.7 version of the notebook if necessary and see if it works.

I actually think that it would be great to create a virtual environment with a list of packages. It would make people's life easier. What do you think ?

paultheastronomer commented 7 years ago

I was running Python 3 all the time as shown by Jupyter in the upper right corner. The issue is that a file is missing:

ERROR:root:File `'fig_config.py'` not found.

Could you perhaps upload this file?

I think that a list of packages are good. If python 2.7 works, great, but don't worry about making it backwards compatible. I am happy to only support Python 3.

pylablanche commented 7 years ago

Oh I see, I know what's wrong now. Give me a minute (or two) and it will be solved.

paultheastronomer commented 7 years ago

Also in In [6] I see that I changed some code by mistake. It says: run gmm_fig_style.py but it should be run fig_config.py.

pylablanche commented 7 years ago

Don't worry I am cleaning my mess now. I have updated the notebook for the original paper as well and forgot to update this one. As a consequence half of the modification were done and of course bugs everywhere. Sorry for that!

paultheastronomer commented 7 years ago

No problem. This is giving me good github practice! :)