module notebookhelper.magic_notebook

Inheritance diagram of pyensae.notebookhelper.magic_notebook

Short summary

module pyensae.notebookhelper.magic_notebook

Magic command to help within notebooks

source on GitHub

Classes

class

truncated documentation

MagicNotebook

Defines magic commands to help with notebooks

Functions

function

truncated documentation

register_notebook_magics

register magics function, can be called from a notebook

Properties

property

truncated documentation

Context

return the context or None

cross_validation_lock

A contextmanager for running a block with our cross validation lock set to True. At the end of the block, …

Static Methods

staticmethod

truncated documentation

jsdf_parser

defines the way to parse the magic command %jsdf

nb_menu_parser

defines the way to parse the magic command %nb_menu

Methods

method

truncated documentation

jsdf

defines %jsdf which displays a pandas dataframe into a notebook using qgrid (javascript)

nb_menu

defines %nb_menu which displays a menu

Documentation

Magic command to help within notebooks

source on GitHub

class pyensae.notebookhelper.magic_notebook.MagicNotebook(**kwargs: Any)

Bases: MagicClassWithHelpers

Defines magic commands to help with notebooks

New in version 1.1.

source on GitHub

Create a configurable given a config config.

Parameters

configConfig

If this is empty, default values are used. If config is a Config instance, it will be used to configure the instance.

parentConfigurable instance, optional

The parent Configurable instance of this object.

Notes

Subclasses of Configurable must call the __init__() method of Configurable before doing anything else and using super():

class MyConfigurable(Configurable):
    def __init__(self, config=None):
        super(MyConfigurable, self).__init__(config=config)
        # Then any other code you need to finish initialization.

This ensures that instances will be configured properly.

_all_trait_default_generators: Dict[str, Any] = {'config': <bound method TraitType.default of <traitlets.traitlets.Instance object>>, 'parent': <bound method TraitType.default of <traitlets.traitlets.Instance object>>}
_cross_validation_lock: bool
_descriptors = [<traitlets.traitlets.ObserveHandler object>, <traitlets.traitlets.Instance object>, <traitlets.traitlets.Instance object>]
_instance_inits = [<bound method ObserveHandler.instance_init of <traitlets.traitlets.ObserveHandler object>>, <bound method Instance.instance_init of <traitlets.traitlets.Instance object>>, <bound method Instance.instance_init of <traitlets.traitlets.Instance object>>]
_static_immutable_initial_values: Dict[str, Any] = {'parent': None}
_trait_default_generators = {}
_trait_notifiers: Dict[str, Any]
_trait_validators: Dict[str, Any]
_trait_values: Dict[str, Any]
_traits: Dict[str, Any] = {'config': <traitlets.traitlets.Instance object>, 'parent': <traitlets.traitlets.Instance object>}
jsdf(line)

defines %jsdf which displays a pandas dataframe into a notebook using qgrid (javascript)

jsdf

The magic command %jsdf displays a dataframe using qgrid module. The code is the following:

import qgrid
if firt_call:
    qgrid.set_defaults(precision=<precision>)
    self.first_jsdf_call = False

df = args.df
grid_options = dict(defaultColumnWidth=<defaultColumnWidth>,
                    enableColumnReorder=<enableColumnReorder>,
                    multiColumnSort=<multiColumnSort>,
                    rowHeight=<rowHeight>,
                    showHeaderRow=<showHeaderRow>,
                    forceFitColumns=<forceFitColumns>,
                    autoHeight=<autoHeight>,
                    enableCellNavigation=<enableCellNavigation>)
qgrid.show_grid(df, grid_options=grid_options)

source on GitHub

static jsdf_parser()

defines the way to parse the magic command %jsdf

source on GitHub

nb_menu(line)

defines %nb_menu which displays a menu

nb_menu

The magic command %nb_menu displays a menu in a notebook. It parses a notebook and displays a menu gathering all sections within that notebook. The code is the following:

from pyquickhelper.ipythonhelper import add_notebook_menu
js = add_notebook_menu(menu_id=<menu_id>, header=<title>, format=<format>,
                    first_level=<level1>, last_level=<level2>,
                    raw=<raw>)

source on GitHub

static nb_menu_parser()

defines the way to parse the magic command %nb_menu

source on GitHub

pyensae.notebookhelper.magic_notebook.register_notebook_magics(ip=None)

register magics function, can be called from a notebook

Parameters:

ip – from get_ipython()

source on GitHub