Closed nirum closed 7 years ago
Just tested this, and the following is all that's needed to get this to work in a Jupyter notebook:
from IPython.display import HTML
anim = pyret.visualizations.playsta(sta)
HTML(anim.to_html5_video())
Closing.
We could add a helper function that runs those three lines of code. or a flag in playsta (html=True
or something) thoughts?
Helper function sounds good to me. I'm not big on returning different types from a function, if we can avoid it. I'll reopen this and add it back now.
Should we now list IPython as an explicit dependency?
Looks like we can put it in setup.py
in the extras_require
kwarg to setup
. See this SO post and the setuptools docs.
https://stackoverflow.com/questions/19096155/setuptools-and-pip-choice-of-minimal-and-complete-install
https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies
Not sure if we then need to include anything in the requirements file, though.
Closed in 59a0405.
This actually seems like something that's already baked into matplotlib's animations. The
FuncAnimation
object returned byvisualizations.playsta()
has ato_html5_video()
method, which returns an HTML<video>
tag containing the encoded movie. It can be directly viewed in a browser.There a pretty straightforward solution on SO for playing a local video in an IPython notebook: https://stackoverflow.com/questions/18019477/how-can-i-play-a-local-video-in-my-ipython-notebook
It can also be made automatic, in the sense that just creating the animation will make it automatically embedded in the notebook. See here for details: https://jakevdp.github.io/blog/2013/05/12/embedding-matplotlib-animations/.