Customizing the Jupyter notebook

These are strictly optional.

1. Creating a startup script

It is convenient to have a bunch of default imports and set up inline plotting automatically. Here’s how to do it.

Create an ipython profile

In [1]:
! ipython profile create

Edit the next cell to set your defaults, then execute it.

In [2]:
%%file ~/.ipython/profile_default/startup/start.ipy

import os
import sys
import glob
import operator as op
import itertools as it
from functools import reduce, partial
import numpy as np
import pandas as pd
from pandas import DataFrame, Series
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_context("notebook", font_scale=1.5)
%matplotlib inline
Overwriting /Users/cliburn/.ipython/profile_default/startup/start.ipy

Stop and restart your Jupyter kernel

2. Change keybindings to emacs

In [3]:
! pip install jupyter-emacskeys
Requirement already satisfied (use --upgrade to upgrade): jupyter-emacskeys in /Users/cliburn/anaconda2/envs/p3/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): ipython>=4 in /Users/cliburn/anaconda2/envs/p3/lib/python3.5/site-packages (from jupyter-emacskeys)
Requirement already satisfied (use --upgrade to upgrade): notebook>=4 in /Users/cliburn/anaconda2/envs/p3/lib/python3.5/site-packages (from jupyter-emacskeys)
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

3. Install slide mode (RISE)

In [4]:
%%bash

git clone https://github.com/damianavila/RISE.git
cd RISE
python setup.py install
fatal: destination path 'RISE' already exists and is not an empty directory.

4. Install Calico extensions (see videos for what they do)

This will not work in the Docker container as you do not have the appropriate permissions. However, you can do this for your local installation if you wish.

In [5]:
import IPython

Spell-check

In [6]:
IPython.display.YouTubeVideo("Km3AtRynWFQ")
Out[6]:

Document tools

In [7]:
IPython.display.YouTubeVideo("YbM8rrj-Bms")
Out[7]:

Cell tools

In [8]:
IPython.display.YouTubeVideo("WwoTzvOkEJQ")
Out[8]:

Execute the next 2 cells to install spell-check, document and cell tools

In [9]:
%%bash

ipython install-nbextension https://bitbucket.org/ipre/calico/downloads/calico-spell-check-1.0.zip
ipython install-nbextension https://bitbucket.org/ipre/calico/downloads/calico-document-tools-1.0.zip
ipython install-nbextension https://bitbucket.org/ipre/calico/downloads/calico-cell-tools-1.0.zip
[TerminalIPythonApp] WARNING | Subcommand `ipython install-nbextension` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter install-nbextension` in the future
Unrecognized JSON config file version, assuming version 1
Downloading: https://bitbucket.org/ipre/calico/downloads/calico-spell-check-1.0.zip -> /var/folders/xf/rzdg30ps11g93j3w0h589q780000gn/T/tmpoxmi5kib/calico-spell-check-1.0.zip
Extracting: /var/folders/xf/rzdg30ps11g93j3w0h589q780000gn/T/tmpoxmi5kib/calico-spell-check-1.0.zip -> /usr/local/share/jupyter/nbextensions
[TerminalIPythonApp] WARNING | Subcommand `ipython install-nbextension` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter install-nbextension` in the future
Unrecognized JSON config file version, assuming version 1
Downloading: https://bitbucket.org/ipre/calico/downloads/calico-document-tools-1.0.zip -> /var/folders/xf/rzdg30ps11g93j3w0h589q780000gn/T/tmpry0dxv_t/calico-document-tools-1.0.zip
Extracting: /var/folders/xf/rzdg30ps11g93j3w0h589q780000gn/T/tmpry0dxv_t/calico-document-tools-1.0.zip -> /usr/local/share/jupyter/nbextensions
[TerminalIPythonApp] WARNING | Subcommand `ipython install-nbextension` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter install-nbextension` in the future
Unrecognized JSON config file version, assuming version 1
Downloading: https://bitbucket.org/ipre/calico/downloads/calico-cell-tools-1.0.zip -> /var/folders/xf/rzdg30ps11g93j3w0h589q780000gn/T/tmpnx_9276n/calico-cell-tools-1.0.zip
Extracting: /var/folders/xf/rzdg30ps11g93j3w0h589q780000gn/T/tmpnx_9276n/calico-cell-tools-1.0.zip -> /usr/local/share/jupyter/nbextensions
In [10]:
%%file ~/.jupyter/custom/custom.js

require(['base/js/utils'],
        function(utils) {
            utils.load_extensions('calico-spell-check',
                                  'calico-document-tools',
                                  'calico-cell-tools');
        });
Overwriting /Users/cliburn/.jupyter/custom/custom.js