giotto-ai / giotto-tda

A high-performance topological machine learning toolbox in Python
https://giotto-ai.github.io/gtda-docs
Other
858 stars 175 forks source link

Mapper tutorial - plot_interactive_mapper_graph #569

Closed ahmed-akader closed 3 years ago

ahmed-akader commented 3 years ago

Describe the bug The very last cell produces a single line of text with no plot

VBox(children=(HBox(children=(VBox(children=(HTML(value='Cover parameters'), Text(value='uniform', cont…

Also, gtda/mapper/tests/test_visualization.py passes

python -m unittest gtda/mapper/tests/test_visualization.py ..

Ran 2 tests in 0.320s

OK

To reproduce Just browse to the mapper tutorial and go to the bottom. Same happened locally.

Expected behavior I've never seen the interactive plot, but I expect it to look like the other plots earlier in the notebook.

ulupo commented 3 years ago

Interactive mapper plots only work (by design) in a jupyter notebook. This is explained in the tutorial. We can also add a note in the API reference page for plot_interactive_mapper_graph.

ahmed-akader commented 3 years ago

Thanks for explaining. I was actually running the jupyter notebook locally and still not getting the plot, just that same line from the webpage.

ulupo commented 3 years ago

Hi @ahmadabdolkader, thanks for getting back. To diagnose, we need to know your config. Please run the following snippet and paste the output below.

import platform; print(platform.platform())
import sys; print("Python", sys.version)
import ipywidgets; print("Ipywidgets", ipywidgets.__version__)
import plotly; print("Plotly", plotly.__version__)
import gtda; print("Giotto-tda", gtda.__version__)

We also should know what version of jupyter you are using, and whether you are using jupyter notebook, jupyter lab or something else, like Google's colab. Only jupyter notebook is supported without extra steps.

ahmed-akader commented 3 years ago

Config

Linux-5.4.0-66-generic-x86_64-with-glibc2.29 Python 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0] Ipywidgets 7.6.3 Plotly 4.14.3 Giotto-tda 0.4.0

I'm using jupyter notebook and this is my version info

$ jupyter --version jupyter core : 4.7.1 jupyter-notebook : 6.2.0 qtconsole : 5.0.2 ipython : 7.13.0 ipykernel : 5.5.0 jupyter client : 6.1.11 jupyter lab : not installed nbconvert : 6.0.7 ipywidgets : 7.6.3 nbformat : 5.1.2 traitlets : 4.3.3

ulupo commented 3 years ago

Thanks! For comparison, as far as jupyter goes, I have been running as follows with no problem:

jupyter core     : 4.7.1
jupyter-notebook : 6.2.0
qtconsole        : 5.0.2
ipython          : 7.20.0
ipykernel        : 5.4.3
jupyter client   : 6.1.11
jupyter lab      : 2.2.8
nbconvert        : 6.0.7
ipywidgets       : 7.6.3
nbformat         : 5.1.2
traitlets        : 5.0.5

So this is a bit strange. Two further questions:

widget = plot_interactive_mapper_graph(...) display(widget)


- Are other, simpler `ipywidgets` automatically displayed in your jupyter notebooks, i.e. without calling `display`?  You can try some of the ones in https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Basics.html for instance.
ahmed-akader commented 3 years ago
* Are you able to display the _static_ plots, using `plot_static_mapper_graph`?

Simply switching to plot_static_mapper_graph still produced some json text.

FigureWidget({ 'data': [{'hoverinfo': 'none', 'line': {'color': '#888', 'width': 1}, …

* Is the widget displayed if you explicitly call `display`?
from IPython.display import display

widget = plot_interactive_mapper_graph(...)
display(widget)

That didn't work for neither the interactive nor the static plots. Using the static plot as fig and calling fig.show() worked as earlier in the mapper notebook.

* Are other, simpler `ipywidgets` automatically displayed in your jupyter notebooks, i.e. without calling `display`?  You can try some of the ones in https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Basics.html for instance.

No. I tried this and got a line of text instead of what's shown on the page.

from IPython.display import display import ipywidgets as widgets w = widgets.IntSlider() display(w)

IntSlider(value=0)

I tried both FireFox and Google Chrome. Same behavior.

I tried upgrading my ipython and traitlets to match up to your setup, and it didn't matter.

jupyter core : 4.7.1 jupyter-notebook : 6.2.0 qtconsole : 5.0.2 ipython : 7.22.0 ipykernel : 5.5.0 jupyter client : 6.1.11 jupyter lab : not installed nbconvert : 6.0.7 ipywidgets : 7.6.3 nbformat : 5.1.2 traitlets : 5.0.5

ulupo commented 3 years ago

Thanks for the detailed report @ahmadabdolkader !

Since it seems you have more fundamental issues with ipywidgets (the simplest possible example does not work) it seems to me that your best bet is to seek a solution within their community/issue tracker. They will likely be able to find a solution for you!