Friday, 9 August 2013

ipython 1.0 notes

The new ipython includes many new features:  so many I'll log some here.  IPython amazes me!  I wonder if I could up sections of my notebooks to blogger.....  anyway.  Much of the following is noted directly from the following address:

http://ipython.org/ipython-doc/stable/interactive/tutorial.html

% timeit range(1000)  # run this one line

%% timeit range(1000) # run this cell.
 max(x)

% run -d myprogram.py # step through the program!

% debug   # now works in the notebook!  As does raw_input() !

System commands!

output = !ping www.bbc.co.uk

.. to provide the command with ipython variables, use $ or wrap in {} as follows:

output = !grep -rF $pattern ipython/*

a = 'hello'
output = !grep -rF {a} ipython/*


Grab external python programs, edit and execute!

%load http://matplotlib.sourceforge.net/plot_directive/mpl_examples/mplot3d/contour3d_demo.py

Set high quality plots:  Put this at the start.

% config InlineBackend.figure_format = 'svg'

Undo :   Thank you!

%connect_info

to display connection info for other ipython consoles.

Setting up clients and workers:

worker:
user@worker: $ ipython kernel
[IPKernelApp] To connect to another client on this kernel, use:
[IPKernelApp] --existing kernel-12345.json

client:
user@client $ ipython qtconsole --ssh=worker --existing /path/to/kernel-12345.json

Manual ssh tunnels.  This is interesting even without ipython.

$ ssh :: -f -N

Blogger mangled.  Check the source at
http://ipython.org/ipython-doc/stable/interactive/qtconsole.html
for this.
















No comments:

Post a Comment