Skip to content

openavmkit.utilities.notebook

Rich output that works both inside Jupyter and in plain Python processes.

OpenAVMKit is usually driven from notebooks, but it is also run headless (scripts, CI, desktop front ends). These helpers use IPython's rich display when a kernel is running and fall back to plain printing otherwise, so IPython is not a hard runtime dependency.

HTML

HTML(html)

Wrap html for rich display if IPython is available, else return it as-is.

Source code in openavmkit/utilities/notebook.py
28
29
30
31
32
33
34
def HTML(html: str):
    """Wrap ``html`` for rich display if IPython is available, else return it as-is."""
    if _in_notebook():
        from IPython.display import HTML as _HTML

        return _HTML(html)
    return html

display

display(obj)

Show obj with IPython's rich display if available, else print it.

Source code in openavmkit/utilities/notebook.py
18
19
20
21
22
23
24
25
def display(obj) -> None:
    """Show ``obj`` with IPython's rich display if available, else print it."""
    if _in_notebook():
        from IPython.display import display as _display

        _display(obj)
    else:
        print(obj)