Open ddundo opened 1 month ago
Actually, the # %% [markdown]
labels aren't necessary and neither are the code cell labels # %%
. Although without the code labels, each empty line in the .py script would mean end of the cell. So e.g.
a = 1
b = 2
would be 2 cells in the notebook. Maybe this could be modified in the jupytext config... not sure.
There are also some jupytext settings for sphinx/rst compatibility. I didn't test this out. But potentially we could keep the demos exactly as they are.
I can test all of this out if we decide to go with the notebooks idea :)
Sounds good, thanks! Happy for you to do this.
Further to our discussion this morning, I converted animate's
simple_metric.py
demo to a format suitable for converting it to a Jupyter notebook using jupytext. This is very simple - I just had to add# %% [markdown]
before text blocks and# %%
before code blocks. This is actually standard formatting - I noticed now that VS code automatically recognised it in the .py script and asked me to run each of these partition interactively. So that's nice too :)So my idea was to keep demos in this .py format and then only convert them to notebooks when building the website. This can be easily done in command line or in a python script, e.g.:
and then the notebook can be executed with
jupytext --execute simple_metric.ipynb
which runs the code and produces figures in the notebook, etc.Here is the demo script if you'd like to test it out: https://gist.github.com/ddundo/32fc425e0e1de246b06b6cf09d903818