Commit d1c10a50 authored by Anton Akhmerov's avatar Anton Akhmerov
Browse files

Merge branch 'remove_code_hiding' into 'master'

Remove code hiding

Closes #153 (code hiding)

See merge request !17
parents 19266dab 6af7ffbd
Pipeline #1308 passed with stages
in 5 minutes and 11 seconds
......@@ -21,9 +21,8 @@ import functions
from functions import *
init_mooc_nb = ['np', 'matplotlib', 'kwant', 'holoviews', 'init_notebook',
'display_html', 'plt', 'pf',
'SimpleNamespace', 'pprint_matrix', 'scientific_number',
'pretty_fmt_complex', 'plt', 'pf', 'display_html']
__all__ = init_mooc_nb + edx_components.__all__ + functions.__all__
......@@ -71,46 +70,6 @@ def pretty_fmt_complex(num, digits=2):
pretty_fmt_complex(num.imag) + 'i')
nb_html_header = """
<script type=text/javascript>
/* Add a button for showing or hiding input */
on = "Show input";
off = "Hide input";
function onoff(){
currentvalue = document.getElementById('onoff').value;
if(currentvalue == off){
/* Launch first notebook cell on start */
function launch_first_cell (evt) {
if (!launch_first_cell.executed
&& Jupyter.notebook.kernel
) {
launch_first_cell.executed = true;
$([]).on('status_started.Kernel notebook_loaded.Notebook', launch_first_cell);
<p>Press this button to show/hide the code used in the notebook:
<input type="button" class="ui-button ui-widget ui-state-default \
ui-corner-all ui-button-text-only" value="Hide input" id="onoff" \
hide_outside_ipython = """<script type=text/javascript>
$(document).ready(function (){if(!("IPython" in window)){onoff();}})
def init_notebook(mpl=True):
# Enable inline plotting in the notebook
if mpl:
......@@ -165,20 +124,6 @@ def init_notebook(mpl=True):
np.set_printoptions(precision=2, suppress=True,
formatter={'complexfloat': pretty_fmt_complex})
# In order to make the notebooks readable through nbviewer we want to hide
# the code by default. However the same code is executed by the students,
# and in that case we don't want to hide the code. So we check if the code
# is executed by one of the mooc developers. Here we do by simply checking
# for some files that belong to the internal mooc repository, but are not
# published. This is a temporary solution, and should be improved in the
# long run.
developer = os.path.exists(os.path.join(module_dir, os.path.pardir,
display_html(display.HTML(nb_html_header +
(hide_outside_ipython if developer else '')))
# Patch a bug in holoviews
if holoviews.__version__.release <= (1, 4, 3):
from patch_holoviews import patch_all
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment