mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-05 09:01:40 -05:00
132 lines
4.1 KiB
Org Mode
132 lines
4.1 KiB
Org Mode
* Tests
|
|
|
|
This is a [[ipynb:(:url-or-port%20"http://localhost:8888"%20:name%20"emacs-ipython-notebook/The%20Emacs%20IPython%20Notebook.ipynb")][link]] to an ein notebook. It might not work if your setup is not the same as mine!
|
|
|
|
|
|
Note that code is executed asynchronously, so executing the following won't
|
|
block Emacs. You can even queue up a number of source code blocks and they will
|
|
execute sequentially as the previous finishes execution!
|
|
|
|
#+NAME: 6d0ec9b7-249c-46e9-bdf1-c48b7bcf7fbd
|
|
#+BEGIN_SRC ein :session http://localhost:8888/The Emacs IPython Notebook.ipynb
|
|
import sys
|
|
import time
|
|
|
|
time.sleep(10)
|
|
print("Hello dood!")
|
|
#+END_SRC
|
|
|
|
#+RESULTS: 6d0ec9b7-249c-46e9-bdf1-c48b7bcf7fbd
|
|
: Hello dood!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#+NAME: 744c7889-aec1-495f-9d07-6efc17329e94
|
|
#+BEGIN_SRC ein :session http://localhost:8888/The Emacs IPython Notebook.ipynb
|
|
1+4
|
|
#+END_SRC
|
|
|
|
#+RESULTS: 744c7889-aec1-495f-9d07-6efc17329e94
|
|
: 5
|
|
|
|
Tracebacks will be printed out, but if you want to use ein's traceback and
|
|
debugging support you have to jump to the ~*ein:shared-output*~ buffer for
|
|
traceback support or the notebook running the session and execute ~%debug~ in a
|
|
cell there.
|
|
|
|
#+NAME: 47c36fa5-1b53-413b-8f5b-814f1ae66a3b
|
|
#+BEGIN_SRC ein :session http://localhost:8888/The Emacs IPython Notebook.ipynb :results output drawer
|
|
1/0
|
|
#+END_SRC
|
|
|
|
#+RESULTS: 47c36fa5-1b53-413b-8f5b-814f1ae66a3b
|
|
:results:
|
|
|
|
ZeroDivisionErrorTraceback (most recent call last)
|
|
<ipython-input-23-9e1622b385b6> in <module>
|
|
----> 1 1/0
|
|
|
|
ZeroDivisionError: division by zero
|
|
:end:
|
|
|
|
#+NAME: 00052904-6ca5-46e0-9797-c6039d0daf5e
|
|
#+BEGIN_SRC ein :session http://localhost:8888/The Emacs IPython Notebook.ipynb :results output drawer
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
%matplotlib inline
|
|
x = np.linspace(0, 1, 100)
|
|
y = np.random.rand(100,1)
|
|
plt.plot(x,y)
|
|
x
|
|
|
|
#+END_SRC
|
|
|
|
#+RESULTS: 00052904-6ca5-46e0-9797-c6039d0daf5e
|
|
:results:
|
|
array([0. , 0.01010101, 0.02020202, 0.03030303, 0.04040404,
|
|
0.05050505, 0.06060606, 0.07070707, 0.08080808, 0.09090909,
|
|
0.1010101 , 0.11111111, 0.12121212, 0.13131313, 0.14141414,
|
|
0.15151515, 0.16161616, 0.17171717, 0.18181818, 0.19191919,
|
|
0.2020202 , 0.21212121, 0.22222222, 0.23232323, 0.24242424,
|
|
0.25252525, 0.26262626, 0.27272727, 0.28282828, 0.29292929,
|
|
0.3030303 , 0.31313131, 0.32323232, 0.33333333, 0.34343434,
|
|
0.35353535, 0.36363636, 0.37373737, 0.38383838, 0.39393939,
|
|
0.4040404 , 0.41414141, 0.42424242, 0.43434343, 0.44444444,
|
|
0.45454545, 0.46464646, 0.47474747, 0.48484848, 0.49494949,
|
|
0.50505051, 0.51515152, 0.52525253, 0.53535354, 0.54545455,
|
|
0.55555556, 0.56565657, 0.57575758, 0.58585859, 0.5959596 ,
|
|
0.60606061, 0.61616162, 0.62626263, 0.63636364, 0.64646465,
|
|
0.65656566, 0.66666667, 0.67676768, 0.68686869, 0.6969697 ,
|
|
0.70707071, 0.71717172, 0.72727273, 0.73737374, 0.74747475,
|
|
0.75757576, 0.76767677, 0.77777778, 0.78787879, 0.7979798 ,
|
|
0.80808081, 0.81818182, 0.82828283, 0.83838384, 0.84848485,
|
|
0.85858586, 0.86868687, 0.87878788, 0.88888889, 0.8989899 ,
|
|
0.90909091, 0.91919192, 0.92929293, 0.93939394, 0.94949495,
|
|
0.95959596, 0.96969697, 0.97979798, 0.98989899, 1. ])
|
|
[[file:ein-images/ob-ein-958ea9b193e7657e6b8b77069728be7a.png]]
|
|
:end:
|
|
|
|
|
|
#+NAME: 84b146f2-0b8d-46ca-9fb9-96759657927c
|
|
#+BEGIN_SRC ein :session http://localhost:8888/The Emacs IPython Notebook.ipynb :results output
|
|
from sympy import *
|
|
|
|
init_printing()
|
|
x = symbols('x')
|
|
x
|
|
|
|
#+END_SRC
|
|
|
|
#+RESULTS: 84b146f2-0b8d-46ca-9fb9-96759657927c
|
|
#+begin_example
|
|
|
|
ModuleNotFoundErrorTraceback (most recent call last)
|
|
<ipython-input-21-a0c2aa571a36> in <module>
|
|
----> 1 from sympy import *
|
|
2
|
|
3 init_printing()
|
|
4 x = symbols('x')
|
|
5 x
|
|
|
|
ModuleNotFoundError: No module named 'sympy'
|
|
#+end_example
|
|
|
|
|
|
* SVG Images
|
|
* Issue #468: Results in org mode
|
|
|
|
#+NAME: ffbf0b19-515a-4966-9220-70063cf2948d
|
|
#+BEGIN_SRC ein :session http://localhost:8888/The Emacs IPython Notebook.ipynb :results value
|
|
import numpy as np
|
|
np.zeros(18)
|
|
#+END_SRC
|
|
|
|
#+RESULTS: ffbf0b19-515a-4966-9220-70063cf2948d
|
|
: array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
|
|
: 0.])
|
|
|