SIRF icon indicating copy to clipboard operation
SIRF copied to clipboard

spyder or jupyter notebooks for interactive demos

Open KrisThielemans opened this issue 7 years ago • 10 comments

for the course, we've decided on jupyter notebooks (assuming it all works!). That will lead to duplication of demos and therefore bugs.

One solution might be to swap to jupyter notebooks and tell people about the spyder plug-in to use jupyter notebooks in spyder. I haven't tried this yet.

By the way, there seems to be a nice feature of jupyter notebooks to be able to generate a new notebook with all output, and then convert it to HTML (or Latex or ...), see here. This would be good for generating documentation.

KrisThielemans avatar May 10 '18 12:05 KrisThielemans

And I've made a script to convert spyder scripts to jupyter notebooks! We can close the circle.

paskino avatar May 10 '18 14:05 paskino

:-) I knew you were not a copy-paste guy.

will be interesting to see the output... Note that there are some fixes on the demos already.

KrisThielemans avatar May 10 '18 14:05 KrisThielemans

After the first file I painstakingly translated I went for the more interesting way. Which enabled me to update the notebook you've updated!

I've got a question: it seems that you need to run the PET interactive samples in a single thread, as one is needed for the other step. Shall I put it all in one notebook?

MR notebooks work like charm.

BTW, you can already try it on any machine with SIRF installed (and jupyter)

paskino avatar May 10 '18 15:05 paskino

great.

RE the PET interactive ones question, does each notebook run with its own kernel? If not, I'd rather avoid it. It otherwise would become a very large notebook. Maybe we could put some stuff in then to avoid the dependency. To discuss tomorrow?

BTW: try, yes. great. but where are they? :-;

KrisThielemans avatar May 10 '18 15:05 KrisThielemans

they are here https://github.com/CCPPETMR/SIRF-Exercises/tree/notebook

Yes, each notebook runs on a different kernel, and to make a notebook connect to another kernel is quite a hack.

paskino avatar May 10 '18 16:05 paskino

notebook convert can output spyder, and/or check the spyder notebook plug-in.

KrisThielemans avatar Jun 01 '18 10:06 KrisThielemans

https://ipython.org/ipython-doc/2/notebook/nbconvert.html

casperdcl avatar Jun 01 '18 10:06 casperdcl

from the link above, we could do ipython nbconvert --config mycfg.py which should hopefully allow us to replace # <codecell> with #%% automatically. If it doesn't we can always run our own script to do the replacement.

casperdcl avatar Jun 01 '18 10:06 casperdcl

update: jupyter nbconvert --to python now does # In [*] instead. This seems to be supportend by spyder (spyder-ide/spyder#1783). I've tested this with latest jupyter and spyder via conda (and nbstripout via pip). I'd recommend:

nbstripout file.ipynb && jupyter nbconvert --to python file.ipynb

casperdcl avatar Jun 01 '18 13:06 casperdcl

would need to be done at install time (see #181) I think

KrisThielemans avatar Aug 30 '19 14:08 KrisThielemans