mythos.ui.loggers.jupyter

Implements a plotly logger for use in Jupyter notebooks.

Attributes

LBL_TOP_HEADER

LBL_PROG_BAR

LBL_SIM_HEADER

LBL_OBS_HEADER

LBL_OBJ_HEADER

WARN_INVALID_NCOLS_NROWS

figure_widget_f

scatter_f

make_subplots_f

Classes

PlotlyLogger

A logger for use in Jupyter notebooks that uses plotly.

JupyterLogger

A logger for use in Jupyter notebooks.

Functions

calc_rows_and_columns(→ tuple[int, int])

Calculate the number of rows and columns for the plot.

setup_figure_layout(→ None)

Setup the layout of the plotly figure.

Module Contents

mythos.ui.loggers.jupyter.LBL_TOP_HEADER = 'Optimization Status'
mythos.ui.loggers.jupyter.LBL_PROG_BAR = 'Optimizing'
mythos.ui.loggers.jupyter.LBL_SIM_HEADER = 'Simulators'
mythos.ui.loggers.jupyter.LBL_OBS_HEADER = 'Observables'
mythos.ui.loggers.jupyter.LBL_OBJ_HEADER = 'Objectives'
mythos.ui.loggers.jupyter.WARN_INVALID_NCOLS_NROWS = 'The number of rows and columns is less than the number of plots. Adjusting the number of rows...
mythos.ui.loggers.jupyter.figure_widget_f
mythos.ui.loggers.jupyter.scatter_f
mythos.ui.loggers.jupyter.make_subplots_f
mythos.ui.loggers.jupyter.calc_rows_and_columns(n_plots: int, nrows: int | None, ncols: int | None) tuple[int, int][source]

Calculate the number of rows and columns for the plot.

Parameters:
  • n_plots – the number of plots

  • nrows – the number of rows in the plot

  • ncols – the number of columns in the plot

Returns:

the number of rows and columns

Return type:

tuple[int, int]

mythos.ui.loggers.jupyter.setup_figure_layout(fig: plotly.graph_objects.FigureWidget, nrows: int, ncols: int, trace_names: list[str | list[str]]) None[source]

Setup the layout of the plotly figure.

Parameters:
  • fig – the plotly figure

  • nrows – the number of rows in the plot

  • ncols – the number of columns in the plot

  • trace_names – the names of the traces

class mythos.ui.loggers.jupyter.PlotlyLogger(observable_plots: list[str | list[str]], nrows: int | None, ncols: int | None, width_px: int | None = None, height_px: int | None = None)[source]

Bases: mythos.ui.loggers.logger.Logger

A logger for use in Jupyter notebooks that uses plotly.

fig
observable_plots
log_metric(name: str, value: float, step: int) None[source]

Log a metric to the plotly figure.

update_status(name: str, status: mythos.ui.loggers.logger.Status) None[source]

Null operation.

change_size(width_px: int | None = None, height_px: int | None = None) None[source]

Change the size of the plotly figure.

Parameters:
  • width_px (int | None) – the width of the figure in pixels

  • height_px (int | None) – the height of the figure in pixels

show() plotly.graph_objects.FigureWidget[source]

Show the plotly figure in a Jupyter notebook.

class mythos.ui.loggers.jupyter.JupyterLogger(simulators: list[str], observables: list[str], objectives: list[str], metrics_to_log: list[list[str] | str], max_opt_steps: int, plots_size_px: tuple[int, int] | None = None, plots_nrows_ncols: tuple[int, int] | None = None)[source]

Bases: mythos.ui.loggers.logger.Logger

A logger for use in Jupyter notebooks.

STATUS_STYLE: ClassVar[dict[mythos.ui.loggers.logger.Status, dict[str, str]]]
prog_bar
sim_btns
obs_btns
obj_btns
btn_map
plots
percent_complete
dashboard
show() ipywidgets.DOMWidget[source]

Show the Jupyter dashboard.

increment_prog_bar(value: int = 1) None[source]

Increment the progress bar by value.

log_metric(name: str, value: float, step: int) None[source]

Log the value for name at step.

Parameters:
  • name (str) – the name of the metric

  • value (float) – the value of the metric

  • step (int) – the step at which the metric was recorded

update_status(name: str, kind: mythos.ui.loggers.logger.StatusKind, status: mythos.ui.loggers.logger.Status) None[source]

Updates the status of a simulator, objective, or observable.