code cheatsheet

mars 2017 blocnote

Python SimpleHTTP serveur

python -m SimpleHTTPServer

Notebook starting lines

In [2]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

Plot

In [9]:
X = np.linspace( 0, 1, 51 )
Y = np.sin( 7*X )

plt.figure(figsize=(12, 4)  )
plt.plot( X, Y,  'k-', alpha=0.7 )
Out[9]:
[<matplotlib.lines.Line2D at 0x7fdf72981fd0>]

Enregistrer un NumpyArray

In [4]:
A = np.array([3, 5])
In [10]:
# Save
A = {'hello':np.array(range(10)), 'u':34}
np.save('test.npy', A) 

# Read
R = np.load('test.npy').item()
print(R) 
{'u': 34, 'hello': array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])}

Liquidtag option (plugin Pelican)

pour masquer le code dans l'affiche de l'article: #<!-- collapse=True -->

In [ ]: