dautil.nb

IPython/Jupyter notebook widgets and utilities.

class dautil.nb.Context(fname)

A mediator for the storing and retrieving of configuration settings.

Variables:fname – Name of the context, this should be unique such as the name of a notebook
read_labels()

Reads the current configuration settings related to the matplotlib.rcParams used by LabelWidget.

Returns:The current configuration settings or None if no settings are found.
read_latex()

Reads the current configuration settings related to the LatexRenderer.

Returns:The current configuration settings or None if no settings are found.
read_rc()

Reads the current configuration settings related to matplotlib.rcParams, which are used by RcWidget.

Returns:The current configuration settings or an empty dict.
update_labels(updates)

Updates the configuration settings related to matplotlib.rcParams used by LabelWidget.

Parameters:updates – Changes to the configuration.
update_latex(updates)

Updates the configuration settings related to LatexRenderer.

Parameters:updates – Changes to the configuration.
update_rc(updates)

Updates the configuration settings related to matplotlib.rcParams used by RcWidget.

Parameters:updates – Changes to the configuration.
class dautil.nb.LabelWidget(nrows=1, ncols=1, context=<dautil.nb.NullContext object at 0x105860518>)

A widget you can use to easily fill in strings for titles, xlabels and ylabels of matplotlib subplots.

Variables:
  • context – A Context instance.
  • labels – A grid of labels.
import dautil as dl
dl.nb.LabelWidget(2, 2, context)
create_mpl_labels_box(row, col, old)

Creates a box with the widgets for a single subplot (cell).

Parameters:
  • row – The row number of the subplot.
  • col – The column number of the subplot.
  • old – The setting for this subplot from a configuration file.
Returns:

The box with widgets.

read_old_labels()

Reads the labels from a configuration file.

update(name, value, row, col)

Updates an internal data structure and related configuration file.

Parameters:
  • name – title, xlabel, legend or ylabel.
  • value – A string representing a label. If needed use curly braces as used by the Python format() string method.
  • row – The number of the row.
  • col – The number of the col.
class dautil.nb.LatexRenderer(chapter=None, start=1, context=None)

Utility class which helps number and render Latex in a IPython/Jupyter notebook.

Variables:
  • chapter – Chapter number.
  • curr – Current equation number.
  • numbers – List of used equation numbers.
  • context – A Context instance.
import dautil as dl
lr = dl.nb.LatexRenderer(chapter=6, start=6, context=context)
lr.render(r'Y_j= \sum _{i=-(m-1)/2}')
number_equation()

Creates a Latex string relating to the numbering of equations.

Returns:A Latex string with the correct equation number.
render(equation)

Renders an equation.

Parameters:equation – A string containing the equation.
class dautil.nb.NullContext

A context following the Null Object Pattern which does nothing

class dautil.nb.PageBuilder(prefix, factory)

Creates a page with widgets for the RcWidget.

Variables:
  • widgets – A dictionary containing widgets.
  • prefix – The prefix for the widget, for instance ‘axes.’.
  • factory – A WidgetFactory.

‘ivar keys: A list of matplotlib properties.

add(widget)

Adds a new widget to the internal dictionary.

Parameters:widget – An IPython HTML widget.
add_color_choosers()

Adds color choosers for relevant properties starting with a prefix such as axes.

build()

Builds an Accordion containing widgets.

Returns:The Accordion with widgets sorted by descriptions.
class dautil.nb.RcWidget(context=None)

This widget configures the matplotlib.rcParams global settings.

Variables:
  • context – A Context instance.
  • factory – A WidgetFactory instance.
axes_page()

Creates a tab page for the matplotlib.rcParams keys which start with axes.

figure_page()

Creates a tab page for the matplotlib.rcParams keys which start with figure.

font_page()

Creates a tab page for the matplotlib.rcParams keys which start with font.

grid_page()

Creates a tab page for the matplotlib.rcParams keys which start with grid.

lines_page()

Creates a tab page for the matplotlib.rcParams keys which start with lines.

print_params(button_instance)

Prints the current matplotlib.rcParams in a textarea.

Parameters:button_instance – The button to click on.
process(param, value)

Processes changes to the GUI and updates matplotlib.rcParams.

Parameters:
  • param – A key in the matplotlib.rcParams dictionary.
  • value – A value in the matplotlib.rcParams dictionary.
class dautil.nb.WidgetFactory(rcw)

A factory for IPython widgets part of the RcWidget GUI.

Variables:rc_widget – A RcWidget instance.
color_chooser(property)

Creates a box with widgets related to choosing a color.

Parameters:property – A color related key in matplotlib.rcParams.
Returns:A box with widgets.
dautil.nb.create_linewidth_slider(desc, *args, **kwargs)

Creates a slider for linewidth-type settings in matplotlib.rcParams.

Parameters:desc – The description label of the widget.
Returns:The configured slider.
dautil.nb.create_month_widget(month, *args, **kwargs)

Creates a dropdown wiget with short month names as labels.

Parameters:month – The month to select by default.
Returns:The configured month widget.
dautil.nb.create_size_slider(desc, *args, **kwargs)

Creates a slider for size-type settings in matplotlib.rcParams.

Parameters:desc – The description label of the widget.
Returns:The configured slider.

Previous topic

dautil.log_api

Next topic

dautil.nlp

This Page