clean

Functions to assist with grading.

class clean.NotebookCleaner

Prepare Jupyter notebooks for distribution to students.

ntbk : string | instance of NotebookNode
The input notebook.
__init__(ntbk)
__repr__()
clear(output=False, content=False, stderr=False, tag=None)

Clear the components of a notebook cell.

output : bool
Whether to clear the output of cells.
content : bool
Whether to clear the content of cells.
stderr : bool
Whether to clear the stderr of cells.
tag : string | None
Only apply clearing to cells with a certain tag.
remove_cells(tag)

Remove cells that contain a specific string.

match_text : str
A string to search for in input cells. Any cells with the match_text inside will be removed.
replace_text(text_replace_begin="### SOLUTION BEGIN", text_replace_end="### SOLUTION END", replace_code=None, replace_md=None)

Create answer cells for students to fill out.

This will remove all text after match_string. Students should then give their answers in this section. Alternatively, a markdown cell will replace the student answer cell

text_replace_begin : str
A string to search for in input cells. If the string is found, then anything between it and text_replace_end is removed.
text_replace_end : str
The ending delimiter for solution cells.
replace_code : str | None
Text to add to code solution cells. If None, nbgrader default is used.
replace_md : str | None
Text to add to markdown solution cells. If None, a default template will be used.
save(path_save)

Save the notebook to disk.

path_save : string
The path for saving the file.