Testing pycell

Hidden execution cells can be used to perform operations that need to be done before the following cells are executed:

import os
os.listdir(".")
a = 1
e = 0
f = 3

This is a cell that should execute automatically:

b = 2
c = a + b
print("The result is {}".format(c))
c

Plotting

This is a cell that should plot and output:

from pylab import *
x = linspace(0, 10, 100)
plot(x, x*x)
show()

To improve quality when exporting to LaTeX, the following code has automatically been run to enable PDF export in notebooks.

from IPython.display import set_matplotlib_formats
set_matplotlib_formats('png', 'pdf')

Ignore output

Predefined output can be omitted by passing --ignore_output to DocOnce. This will remove all environments ending with out.

a = 2
print(a)

2

Not executed

This is a code block that should not be executed:

while True:
    i = 2

This is some formatted stuff, which is underlined and stuff and maybe even contains \( a + 2b \).

Code with errors

If code contains errors, it will still be run and the exception shown as part of the output:

for a in range(10)
    print(a)

Open file

with open("../LICENSE") as f:
    print(f.read())