Jupyter Notebook extension - %%stan magic


I have created a very basic %%stan magic extension to maintain the stan worklow within jupyter notebook . Once a PR for codemirror stan mode gets through (syntax highlighting/autocomplete) could be enabled.

Install: pip install git+https://github.com/Arvinds-ds/stanmagic.git
Extension page: https://github.com/Arvinds-ds/stanmagic
Sample notebook: https://github.com/Arvinds-ds/stanmagic/blob/master/StanMagic-Help.ipynb

Its very preliminary and more of a hacked POC but some may find it useful as I have during the past week.


Have also created a basic notebook extension to do automatic syntax highlighting for %%stan code cells




Hi, I could install and enable it. But failed to load it.

jupyter nbextension list


  Known nbextensions:
  config dir: /Users/ahartikainen/.jupyter/nbconfig
    notebook section
      stan_code_helper/main  enabled 
      - Validating: OK
  config dir: /Users/ahartikainen/miniconda2/envs/py36/etc/jupyter/nbconfig
    notebook section
      jupyter-js-widgets/extension  enabled 
      - Validating: OK
      jupyter-vega/index  enabled 
      - Validating: OK

So I guess I have something wrong with my jupyter / ipython? Any ideas.


What is the error you are getting?. Your extension log looks ok to me. You need to install the Stanmagic extension first. stanmagic installs the extension for saving/compile checking stan code in Jupyter notebooks. stan_helper_code is some javascript code that enables syntax highlighting. It is an optional extension that requires stanmagic. I have got a couple of queries on this. I have updated the README to highlight this requirement.



I just edited my reply above…


Great, it works. I forgot to install stanmagic.


Thanks for all the feedback. Didn’t realize there were many pystan users!. Thanks to @ahartikainen for suggesting improvements. I have updated the stanmagic package (https://github.com/Arvinds-ds/stanmagic.git) with few of your requests including syntax colored HTML formatting of stan code output using pygments.


The more people get involved writing cool new features, the more PyStan users we’ll have!

So, thanks!