4.6.10 pde.tools.output module

Python functions for handling output

get_progress_bar_class

returns a class that behaves as progress bar.

display_progress

displays a progress bar when iterating

in_jupyter_notebook

checks whether we are in a jupyter notebook

BasicOutput

class that writes text line to stdout

JupyterOutput

class that writes text lines as html in a jupyter cell

class BasicOutput(stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)[source]

Bases: OutputBase

class that writes text line to stdout

Parameters:

stream – The stream where the lines are written

show()[source]

shows the actual text

class JupyterOutput(header='', footer='')[source]

Bases: OutputBase

class that writes text lines as html in a jupyter cell

Parameters:
  • header (str) – The html code written before all lines

  • footer (str) – The html code written after all lines

show()[source]

shows the actual text

class OutputBase[source]

Bases: object

base class for output management

abstract show()[source]

shows the actual text

display_progress(iterator, total=None, enabled=True, **kwargs)[source]

displays a progress bar when iterating

Parameters:
  • iterator (iter) – The iterator

  • total (int) – Total number of steps

  • enabled (bool) – Flag determining whether the progress is display

  • **kwargs – All extra arguments are forwarded to the progress bar class

Returns:

A class that behaves as the original iterator, but shows the progress alongside iteration.

get_progress_bar_class(fancy=True)[source]

returns a class that behaves as progress bar.

This either uses classes from the optional tqdm package or a simple version that writes dots to stderr, if the class it not available.

Parameters:

fancy (bool) – Flag determining whether a fancy progress bar should be used in jupyter notebooks (if ipywidgets is installed)

in_jupyter_notebook()[source]

checks whether we are in a jupyter notebook

Return type:

bool