In [33]:
from IPython.display import Latex
Latex(r"$\sqrt{x^2+y^2}$")


Out[33]:
$\sqrt{x^2+y^2}$

In [2]:
from IPython.external.mathjax import install_mathjax
install_mathjax()


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-9209d90709e3> in <module>()
----> 1 from IPython.external.mathjax import install_mathjax
      2 install_mathjax()

ImportError: cannot import name 'install_mathjax'

In [14]:
%reload_ext sympyprinting
#from sympy import *
#import sympy
from sympy import init_printing
init_printing()
x, y = symbols("x,y")
sqrt(x**2+y**2)


/home/supermap/anaconda3/envs/GISpark/lib/python3.5/site-packages/IPython/extensions/sympyprinting.py:31: UserWarning: The sympyprinting extension has moved to `sympy`, use `from sympy import init_printing; init_printing()`
  warnings.warn("The sympyprinting extension has moved to `sympy`, "
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-14-2e02b2f1da3e> in <module>()
      2 #from sympy import *
      3 #import sympy
----> 4 from sympy import init_printing
      5 init_printing()
      6 x, y = symbols("x,y")

ImportError: No module named 'sympy'
from IPython.display import Image Image(filename="python.png")

In [16]:
import cv2
import numpy as np
from IPython.display import Image
img = np.random.randint(0,255,(250,250,3))
cv2.blur(img, (11,11), img)
r, dat = cv2.imencode(".png",img)
Image(dat.tostring())


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-16-d79b771ba93f> in <module>()
      3 from IPython.display import Image
      4 img = np.random.randint(0,255,(250,250,3))
----> 5 cv2.blur(img, (11,11), img)
      6 r, dat = cv2.imencode(".png",img)
      7 Image(dat.tostring())

TypeError: Layout of the output array dst is incompatible with cv::Mat (step[ndims-1] != elemsize or step[1] != elemsize*nchannels)

In [19]:
from IPython.display import Javascript
Javascript("alert('JavaScript call, ok!客户端调用')")


Out[19]:

In [25]:
%timeit 1 + 1
%timeit 1.0 + 1.0
%timeit "1" + "1"

#10000000 loops, best of 3: 52 ns per loop
#10000000 loops, best of 3: 53.4 ns per loop
#10000000 loops, best of 3: 50.9 ns per loop

#%%timeit
s = 0
for i in range(100):
    s += i

#100000 loops, best of 3: 11 us per loop


The slowest run took 62.86 times longer than the fastest. This could mean that an intermediate result is being cached.
10000000 loops, best of 3: 17.5 ns per loop
10000000 loops, best of 3: 14 ns per loop
The slowest run took 85.72 times longer than the fastest. This could mean that an intermediate result is being cached.
10000000 loops, best of 3: 16.3 ns per loop

In [26]:
%pylab inline
plot(random.randn(100));


Populating the interactive namespace from numpy and matplotlib
%load http://matplotlib.org/mpl_examples/pylab_examples/histogram_demo.py #!/usr/bin/env python import numpy as np import matplotlib.mlab as mlab import matplotlib.pyplot as plt mu, sigma = 100, 15 x = mu + sigma*np.random.randn(10000) # the histogram of the data n, bins, patches = plt.hist(x, 50, normed=1, facecolor='green', alpha=0.75) # add a 'best fit' line y = mlab.normpdf( bins, mu, sigma) l = plt.plot(bins, y, 'r--', linewidth=1) plt.xlabel('Smarts') plt.ylabel('Probability') plt.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=100,\ \sigma=15$') plt.axis([40, 160, 0, 0.03]) plt.grid(True) plt.show()

In [29]:
%%prun
for i in range(100):
    linalg.det(random.rand(10,10))


 

In [ ]: