Let's start with some background on what IPython is, then we can talk about what parallel IPython is, and why it makes sense.
def foo():
"""docstring"""
return 'hi'
foo()
def bar():
print 'hi'
from __future__ import print_function
import time
for i in range(10):
time.sleep(0.25)
print(i, end=' ')
import numpy as np
import ctypes
libc = ctypes.CDLL('libc.dylib')
libc.time(-1)
print("I'm okay!")
import numpy as np
np.
np.linspace?
!date
ls
files = !ls
for f in files:
print(repr(f))
%magics
¶biglist = range(1000000)
bigset = set(biglist)
item = biglist[0]
%timeit item in biglist
%timeit item in bigset
def inner(x):
return 1/x
def outer(y):
return inner(1-y)
z = 2
outer(-z + 3)
%debug
%lsmagic
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from scipy.special import jn
x = np.linspace(0,10)
for n in range(5):
plt.plot(x, jn(n,x))
%%latex
\begin{eqnarray}
\nabla \times \vec{\mathbf{B}} &
- \frac{1}{c} \frac{\partial\vec{\mathbf{E}}}{\partial t}
& = & \frac{4 \pi}{c} \vec{\mathbf{j}} \\
\nabla \cdot \vec{\mathbf{E}} && = & 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}} &
+ \frac{1}{c} \frac{\partial\vec{\mathbf{B}}}{\partial t}
& = & \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} && = & 0
\end{eqnarray}
import sympy
sympy.init_printing(use_latex='mathjax')
x = sympy.symbols('x')
expr = x**10-1
expr
sympy.factor(expr)
from IPython.display import display
from IPython.html.widgets import interact
@interact
def factorit(n=10):
display(sympy.factor(x**n-1))
from IPython.display import Image, YouTubeVideo
Image("figs/darts.png")
YouTubeVideo('BROWqjuTM0g ')
We also have
var foo = $(".class");
name = "Background"
!head -n 100 {name}.ipynb | pygmentize -l json
!ipython nbconvert {name}.ipynb --to html
from IPython.display import display, HTML
display(HTML("<a href='{name}.html' target='_blank'>{name}.html</a>".format(name=name)))
Message type: execute_request
content = {
# Source code to be executed by the kernel, one or more lines.
'code' : str,
# A boolean flag which, if True, signals the kernel to execute
# this code as quietly as possible.
'silent' : bool,
# A boolean flag which, if True, signals the kernel to populate history
# The default is True if silent is False. If silent is True, store_history
# is forced to be False.
'store_history' : bool,
...
}
Message type: execute_reply
content = {
# One of: 'ok' OR 'error'
'status' : str,
# The global kernel counter that increases by one with each request that
# stores history. This will typically be used by clients to display
# prompt numbers to the user. If the request did not store history, this will
# be the current value of the counter in the kernel.
'execution_count' : int,
}
Message type: display_data
content = {
# The data dict contains key/value pairs, where the kids are MIME
# types and the values are the raw data of the representation in that
# format.
'data' : dict,
# Any metadata that describes the data
'metadata' : dict,
}
%%javascript
IPython.notebook.kernel.execute("a=1");
print(a)
The protocol is publicly documented, and language agnostic.
Let's see a quick demo, and then find out in more detail.