Charles Stanhope led an informative and engaging discussion of
the IPython Notebook to an enthusiastic audience at the
third
EAST Knowledge meeting. Charles has been using the Notebook to
good effect at work, and demonstrated several notebooks to the
audience. Charles has helped make his demonstration notebooks available. The notebooks are available on the
EAST Knowledge github page. You can also see static versions of the executed pages using the
nbviewer service. The introduction notebook contains links to additional resources that may be useful if you wish to install IPython Notebook yourself.
With IPython Notebooks, individuals and groups can:
- Rapidly prototype and explore algorithmic ideas
- Easily share results
- Replicate work
- Freely collaborate
- Leverage a large body of existing libraries
Alternatives to the notebook such as Mathematica or LabView are
expensive, so businesses often elect to purchase licenses for
only a few people — the Research and Development team, for
example. When it's time to share the results with those who do
not have access to the tools, the team has to prepare a report
— perhaps a (necessarily static) pdf. The report is a poor
substitute for an interactive demo. With a notebook, you can
delve into the code and experiment with the algorithms
yourself.
The IPython Notebook interface runs in your browser, and you don't need to
know any Python to view or modify the contents. Charles set up
a server running the IPython kernel on one laptop, and audience
members connected through a router using their browsers. The setup
demonstrated that IPython genuinely works cross-platform, and
that users need not install anything (except a browser) on
their local machines.
Notebooks consist of "cells" of different types:
| Markdown | - for expository content |
| Code | - for actual computing |
| Headings | - for providing linkable sections |
| Raw | - for just raw text or for disabling code cells |
Code cells produce output that appears inline with the
document. Charles demonstrated a
notebook he developed to explore the
Karplus-Strong algorithm that Jim Rulla presented to the group
in our second
meeting. The
algorithm synthesizes random input into sounds that sound
remarkably like plucked strings. You can adjust the pitch, see
the graph of the waveform, and play the sound in the notebook (even the
static notebook has a sound you can play).
Imagine how much more you'd learn — and how much more fun
you'd have — by playing with the algorithm than by simply
reading this description!
Other examples Charles developed include a csv
(comma-separated-value) file reader with data plots and a
Mandelbrot Set generator.
Tips:
- The IPython and Python online help are helpful.
- Type "help()" in a code cell to bring up Python's interactive help.
- Click the "Help" menu item for much useful information.
- Press Enter to edit a cell, and ESC or + Enter to enter
"command mode". These and other keyboard shortcuts are
available under the Help menu item.
- Use the Cell menu item to Run the code.
- Pat Nystrom discovered that, if the kernel is running locally,
disabling the "inlining" of matplotlib brings up plot
windows with zoom buttons and scroll bars — a useful
discovery, indeed!
We'd like to thank the Multnomah County Library in Gresham for providing space and equipment for EAST Knowledge to meet.
Resources:
- http://github.com/eastknowledge/ipython-intro - EAST Knowledge github page for notebooks
- http://nbviewer.ipython.org/github/eastknowledge/ipython-intro/tree/executed/ - Static examples of executed notebooks