Jupyter – ipython

Utility tips

# reload modules for every 2 seconds
#    use for experiment with new modules
%load_ext autoreload
%autoreload 2

# to make results reproduceble
import numpy as np
seed = 7 * 9

# plotting
import matplotlib.pyplot as plt
%matplotlib inline

# disable simple warnings
import warnings

Ipython/ Jupyter – Interactive Functions Introduction


from __future__ import print_function
from ipywidgets import interact, interactive, fixed
import ipywidgets as widgets


# function
f = lambda x: return x

# user input slider
interact(f, x=10);

Usecase2: How to set default values and a range?

def f(x=80): return x

interact(f, x=(0, 100, 0.5);

Ipython-Jupyter UI Enhancements

Try complete themes from https://github.com/dunovank/jupyter-themes

Try custom and more versatile options from https://github.com/transcranial/jupyter-themer

For Jupter-themer, let us have a UI extension to make it easy for us. https://github.com/merqurio/jupyter_themes

# check if folder is already there
ls -l $(jupyter --data-dir)/nbextensions

# If required* create folder (optional)
mkdir -p $(jupyter --data-dir)/nbextensions

# creating a sub-folder for Jupyter extensions to reside (optional)
cd $(jupyter --data-dir)/nbextensions

# create a folder for themes
$ mkdir jupyter_themes && cd jupyter_themes

# downloading themes code
$ wget https://raw.githubusercontent.com/merqurio/jupyter_themes/master/theme_selector.js

# Activate the extension
$ cd ../ && jupyter nbextension enable jupyter_themes/theme_selector

* http://ipywidgets.readthedocs.io/en/latest/examples/Using%20Interact.html