holoviews.ipython.preprocessors module#

Prototype demo:

python holoviews/ipython/convert.py Conversion_Example.ipynb | python

class holoviews.ipython.preprocessors.OptsMagicProcessor(**kwargs: Any)[source]#

Bases: Preprocessor

Preprocessor to convert notebooks to Python source to convert use of opts magic to use the util.opts utility instead.

preprocess_cell(cell, resources, index)[source]#

Override if you want to apply some preprocessing to each cell. Must return modified cell and resource dictionary.

Parameters#

cellNotebookNode cell

Notebook cell being processed

resourcesdictionary

Additional resources used in the conversion process. Allows preprocessors to pass variables into the Jinja engine.

indexint

Index of the cell being processed

class holoviews.ipython.preprocessors.OutputMagicProcessor(**kwargs: Any)[source]#

Bases: Preprocessor

Preprocessor to convert notebooks to Python source to convert use of output magic to use the util.output utility instead.

preprocess_cell(cell, resources, index)[source]#

Override if you want to apply some preprocessing to each cell. Must return modified cell and resource dictionary.

Parameters#

cellNotebookNode cell

Notebook cell being processed

resourcesdictionary

Additional resources used in the conversion process. Allows preprocessors to pass variables into the Jinja engine.

indexint

Index of the cell being processed

class holoviews.ipython.preprocessors.StripMagicsProcessor(**kwargs: Any)[source]#

Bases: Preprocessor

Preprocessor to convert notebooks to Python source to strips out all magics. To be applied after the preprocessors that can handle holoviews magics appropriately.

preprocess_cell(cell, resources, index)[source]#

Override if you want to apply some preprocessing to each cell. Must return modified cell and resource dictionary.

Parameters#

cellNotebookNode cell

Notebook cell being processed

resourcesdictionary

Additional resources used in the conversion process. Allows preprocessors to pass variables into the Jinja engine.

indexint

Index of the cell being processed

class holoviews.ipython.preprocessors.Substitute(**kwargs: Any)[source]#

Bases: Preprocessor

An nbconvert preprocessor that substitutes one set of HTML data output for another, adding annotation to the output as required.

The constructor accepts the notebook format version and a substitutions dictionary:

{source_html:(target_html, annotation)}

Where the annotation may be None (i.e. no annotation).

preprocess_cell(cell, resources, index)[source]#

Override if you want to apply some preprocessing to each cell. Must return modified cell and resource dictionary.

Parameters#

cellNotebookNode cell

Notebook cell being processed

resourcesdictionary

Additional resources used in the conversion process. Allows preprocessors to pass variables into the Jinja engine.

indexint

Index of the cell being processed

replace(src)[source]#

Given some source html substitute and annotated as applicable

holoviews.ipython.preprocessors.comment_out_magics(source)[source]#

Utility used to make sure AST parser does not choke on unrecognized magics.

holoviews.ipython.preprocessors.filter_magic(source, magic, strip=True)[source]#

Given the source of a cell, filter out the given magic and collect the lines using the magic into a list.

If strip is True, the IPython syntax part of the magic (e.g. %magic or %%magic) is stripped from the returned lines.

holoviews.ipython.preprocessors.replace_line_magic(source, magic, template='{line}')[source]#

Given a cell’s source, replace line magics using a formatting template, where {line} is the string that follows the magic.

holoviews.ipython.preprocessors.strip_magics(source)[source]#

Given the source of a cell, filter out all cell and line magics.

holoviews.ipython.preprocessors.wrap_cell_expression(source, template='{expr}')[source]#

If a cell ends in an expression that could be displaying a HoloViews object (as determined using the AST), wrap it with a given prefix and suffix string.

If the cell doesn’t end in an expression, return the source unchanged.