from IPython.display import Image
Image(url='http://imgs.xkcd.com/comics/new_pet.png')
Comic: XKCD: New Pet
We have an IPython in-depth tutorial that you can download. And you can watch it all online:
from IPython.display import YouTubeVideo
YouTubeVideo('xe_ATRmw0KM') # Part 1/3, the whole 3-part thing is 3 hours
YouTubeVideo('A8VbS-YX2Lo') # Part 2/3
YouTubeVideo('4tJKZWWRs6s') # Part 3/3
%matplotlib inline
from matplotlib.pyplot import plot
plot?
%pdoc plot
%psource plot
%connect_info
%qtconsole
Finding useful examples in the matplotlib gallery.
# Might need to install R and rpy2
%load_ext rpy2.ipython
import numpy as np
X = np.arange(100)
Y = 200.*X + 100.
%%R -i X,Y -o XYcoeff
XYlm = lm(Y~X)
print(summary(XYlm))
XYcoeff = coef(XYlm)
par(mfrow=c(2,2))
plot(XYlm)
print(XYcoeff)
# Might need to install Octave and oct2py
%load_ext octavemagic
%%octave -s 600,200 -f png
subplot(121);
[x,y] = meshgrid(0:0.1:3);
r = sin(x-0.5).^2 + cos(y-0.5).^2;
surf(x,y,r);
subplot(122);
sombrero()
%load_ext cython
def f(x):
return x**2-x
def integrate_f(a, b, N):
s = 0
dx = (b-a)/N
for i in range(N):
s += f(a+i*dx)
return s * dx
%%cython
cdef double f(double x):
return x**2-x
def cyintegrate_f(double a, double b, int N):
cdef int i
cdef double s, dx
s = 0
dx = (b-a)/N
for i in range(N):
s += f(a+i*dx)
return s * dx
a, b, N = 0, 2, 10000
%timeit integrate_f(a, b, N)
%timeit cyintegrate_f(a, b, N)
%%ruby
s = "Yo IPython, Ruby's here 4 real!"
s.split(" ").each do |word|
puts word if word.to_i.to_s == word
end