Jupyter
Start Jupyter notebook
ipython notebook
jupyter notebook
Run cell
Shift-Enter, implement the current cell and move to the next cell
Ctrl-Enter, implment the current cell and stay in the current cell
Alt-Enter, implement the current cell and insert a new cell below
Ipython Display System
from IPython.display import display
from IPython.display import Image
i = Image(filename='Python.jpeg'); # create an image from a filename
i2 = Image(url='http://www.ecsu.edu/_resources/images/logos/ecsulogo_original_450px.png'); # create an image from an url
display(i)
display(i2)
from IPython.display import YouTubeVideo
YouTubeVideo('_GtFn3h6uDM')
from IPython.core.display import HTML
HTML('http://www.google.com')
from IPython.display import Math
Math(r'F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx')
from IPython.display import Latex
Latex(r"""\begin{align} e^{i\pi} + 1 = 0 \end{align}""")
%%latex
\begin{align} e^{i\pi} + 1 = 0 \end{align}
Latex under markdown mode
Inline expressions, $e^{i\pi} + 1 = 0$
Expressions on their own line, $$e^x=\sum_{i=0}^\infty \frac{1}{i!}x^i$$
Code blocks
```python
import scipy
```
Ipython built-in commands
object?, print all sorts of details about any object
%alias, define an alias for a system command
%env, get the environment variables
%history, print input history
%load, load code into the current frontend
%lsmagic, list currently available magic functions
%pylab, load numpy and matplotlib to work interactively
%quickref, get the ipython reference
%run hello.py, run a python script
%timeit, measure the running time
%who, print all interactive variables
%%bash, run cells with bash in a subprocess
%%html, render the cell as a block of HTML
%%javascript, run the cell block of Javascript code
%%js, run the cell block of Javascript code
%%latex, render the cell as a block of latex
%%markdown, render the cell as Markdown text block
%%python2, %%python2 script magic
%%python3, %%python3 script magic
%%sh, %%sh script magic
%%writefile, Write the contents of the cell to a file
System shell commands
!, run command
!ping www.google.com, ping a ip address
d = !ls, save the outputs of the command to a variable
Caching system
Input caching system
- In, a list of all inputs
- _i, _ii, _iii, store previous, next previous and next-next previous inputs
Output caching system
- [_], [__], [___], stores previous, next previous and next-next previous outputs
Checkpoint and revert
Click "Save" button to create a checkpoint
File -> Revert to Checkpoint
%autosave 1000 # automatically save every 1000 seconds
Reference