Skip to content

Bokeh

pytao.plotting.bokeh

Classes

pytao.plotting.bokeh.BokehAppCreator
BokehAppCreator(manager, graphs, share_x=None, include_variables=False, grid=None, width=None, height=None, include_layout=False, graph_sizing_mode=None, layout_height=None, xlim=None, ylim=None, ix_uni=None)

A composite Bokeh application creator made up of 1 or more graphs.

This can be used to: * Generate a static HTML page without Python widgets * Generate a Notebook (or standalone) application with Python widgets

Interactive widgets will use the Tao object to adjust variables during callbacks resulting from user interaction.

Source code in pytao/plotting/bokeh.py
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
def __init__(
    self,
    manager: BokehGraphManager | NotebookGraphManager,
    graphs: list[AnyGraph],
    share_x: bool | None = None,
    include_variables: bool = False,
    grid: tuple[int, int] | None = None,
    width: int | None = None,
    height: int | None = None,
    include_layout: bool = False,
    graph_sizing_mode: SizingModeType | None = None,
    layout_height: int | None = None,
    xlim: OptionalLimit | Sequence[OptionalLimit] = None,
    ylim: OptionalLimit | Sequence[OptionalLimit] = None,
    ix_uni: int | None = None,
) -> None:
    if not len(graphs):
        raise ValueError("BokehAppCreator requires 1 or more graph")

    if any(isinstance(graph, LatticeLayoutGraph) for graph in graphs):
        include_layout = False
    elif not any(graph.is_s_plot for graph in graphs):
        include_layout = False

    if not grid:
        grid = (len(graphs), 1)

    if include_layout:
        grid = (grid[0] + 1, grid[1])

    if include_variables:
        variables = Variable.from_tao_all(manager.tao)
    else:
        variables = []

    self.manager = manager
    self.graphs = graphs
    self.share_x = share_x
    self.variables = variables
    self.grid = grid
    self.width = width
    self.height = height
    self.graph_sizing_mode = graph_sizing_mode
    self.include_layout = include_layout
    self.layout_height = layout_height
    self.ix_uni = ix_uni
    self.xlim = fix_grid_limits(xlim, num_graphs=len(graphs))
    self.ylim = fix_grid_limits(ylim, num_graphs=len(graphs))
Methods:
pytao.plotting.bokeh.BokehAppCreator.create_state
create_state()

Create an independent application state based on the graph data.

Source code in pytao/plotting/bokeh.py
1496
1497
1498
1499
1500
1501
1502
1503
1504
def create_state(self) -> BokehAppState:
    """Create an independent application state based on the graph data."""
    pairs, layout_pairs = self._create_figures()
    grid = self._grid_figures(pairs, layout_pairs)
    return BokehAppState(
        pairs=pairs,
        layout_pairs=layout_pairs,
        grid=grid,
    )
pytao.plotting.bokeh.BokehGraphManager
BokehGraphManager(tao)

Bases: GraphManager

Bokeh backend graph manager - for non-Jupyter contexts.

Source code in pytao/plotting/plot.py
1406
1407
1408
1409
def __init__(self, tao: Tao) -> None:
    self.tao = tao
    self.regions = {}
    self._to_place = {}
Methods:
pytao.plotting.bokeh.BokehGraphManager.plot
plot(template, *, region_name=None, include_layout=True, sizing_mode=None, width=None, height=None, layout_height=None, share_x=None, xlim=None, ylim=None, save=None, curves=None, settings=None, ix_uni=None)

Plot a graph with Bokeh.

Parameters:

Name Type Description Default
template str

Graph template name.

required
region_name str

Graph region name.

None
include_layout bool

Include a layout plot at the bottom, if not already placed and if appropriate (i.e., another plot uses longitudinal coordinates on the x-axis).

True
sizing_mode Optional[SizingModeType]

Set the sizing mode for all graphs. Default is configured on a per-graph basis, typically "inherit".

None
width int

Width of each plot.

None
height int

Height of each plot.

None
layout_height int

Height of the layout plot.

None
share_x bool or None

Share x-axes where sensible (None) or force sharing x-axes (True) for all plots.

None
xlim (float, float)

X axis limits.

None
ylim (float, float)

Y axis limits.

None
curves Dict[int, TaoCurveSettings]

Dictionary of curve index to curve settings. These settings will be applied to the placed graph prior to plotting.

None
settings TaoGraphSettings

Graph customization settings.

None
save str or bool

Save the plot to a static HTML file with the given name. If True, saves to a filename based on the plot title.

None
ix_uni int

Plot data from this universe.

None

Returns:

Type Description
list of graphs
BokehAppCreator
Source code in pytao/plotting/bokeh.py
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
def plot(
    self,
    template: str,
    *,
    region_name: str | None = None,
    include_layout: bool = True,
    sizing_mode: SizingModeType | None = None,
    width: int | None = None,
    height: int | None = None,
    layout_height: int | None = None,
    share_x: bool | None = None,
    xlim: tuple[float, float] | None = None,
    ylim: tuple[float, float] | None = None,
    save: bool | str | pathlib.Path | None = None,
    curves: dict[int, TaoCurveSettings] | None = None,
    settings: TaoGraphSettings | None = None,
    ix_uni: int | None = None,
) -> tuple[list[AnyGraph], BokehAppCreator]:
    """
    Plot a graph with Bokeh.

    Parameters
    ----------
    template : str
        Graph template name.
    region_name : str, optional
        Graph region name.
    include_layout : bool
        Include a layout plot at the bottom, if not already placed and if
        appropriate (i.e., another plot uses longitudinal coordinates on
        the x-axis).
    sizing_mode : Optional[SizingModeType]
        Set the sizing mode for all graphs.  Default is configured on a
        per-graph basis, typically "inherit".
    width : int, optional
        Width of each plot.
    height : int, optional
        Height of each plot.
    layout_height : int, optional
        Height of the layout plot.
    share_x : bool or None, default=None
        Share x-axes where sensible (`None`) or force sharing x-axes (True)
        for all plots.
    xlim : (float, float), optional
        X axis limits.
    ylim : (float, float), optional
        Y axis limits.
    curves : Dict[int, TaoCurveSettings], optional
        Dictionary of curve index to curve settings. These settings will be
        applied to the placed graph prior to plotting.
    settings : TaoGraphSettings, optional
        Graph customization settings.
    save : str or bool, optional
        Save the plot to a static HTML file with the given name.
        If `True`, saves to a filename based on the plot title.
    ix_uni : int, optional
        Plot data from this universe.

    Returns
    -------
    list of graphs

    BokehAppCreator
    """
    graphs = self.prepare_graphs_by_name(
        template_name=template,
        region_name=region_name,
        curves=curves,
        settings=settings,
        xlim=xlim,
        ylim=ylim,
        ix_uni=ix_uni,
    )

    if not graphs:
        raise UnsupportedGraphError(f"No supported plots from this template: {template}")

    app = BokehAppCreator(
        manager=self,
        graphs=graphs,
        share_x=share_x,
        include_variables=False,
        grid=None,
        width=width or _Defaults.width,
        height=height or _Defaults.height,
        layout_height=layout_height or _Defaults.layout_height,
        include_layout=include_layout,
        graph_sizing_mode=sizing_mode,
        xlim=[xlim],
        ylim=[ylim],
        ix_uni=ix_uni,
    )

    if save:
        if save is True:
            save = ""
        filename = app.save(save)
        logger.info(f"Saving plot to {filename!r}")

    return graphs, app
pytao.plotting.bokeh.BokehGraphManager.plot_ele_methods
plot_ele_methods(data, *, columns=None, show_names=True, show_csr_ds_step=None, include_layout=True, lane_height=0.8, width=None, height=None, layout_height=None, save=None)

Plot element method settings as categorical lanes along the beamline.

Each method (e.g., tracking_method) becomes a horizontal lane, with each element drawn as a block spanning its longitudinal extent, colored by the method value.

Parameters:

Name Type Description Default
data ElementMethodsPlotData

Per-element method data, gathered via ElementMethodsPlotData.from_tao.

required
columns sequence of str

Method columns to plot, in order. Defaults to all categorical columns with data for the selected elements.

None
show_names bool

Label method transitions with the element names before and after the transition point.

True
show_csr_ds_step bool

Add a subplot of csr_ds_step vs s. The default (None) shows it only when CSR is active for at least one selected element.

None
include_layout bool

Include a lattice layout plot at the bottom.

True
lane_height float

Height of each lane's blocks, where lanes are spaced 1.0 apart.

0.8
width int

Width of each plot in pixels.

None
height int

Height of the lane plot in pixels. Defaults to scaling with the number of lanes.

None
layout_height int

Height of the layout plot in pixels.

None
save Path or str

Save the plot to the given filename.

None

Returns:

Type Description
ElementMethodsPlotData
column
Source code in pytao/plotting/bokeh.py
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
def plot_ele_methods(
    self,
    data: ElementMethodsPlotData,
    *,
    columns: Sequence[str] | None = None,
    show_names: bool = True,
    show_csr_ds_step: bool | None = None,
    include_layout: bool = True,
    lane_height: float = 0.8,
    width: int | None = None,
    height: int | None = None,
    layout_height: int | None = None,
    save: bool | str | pathlib.Path | None = None,
):
    """
    Plot element method settings as categorical lanes along the beamline.

    Each method (e.g., `tracking_method`) becomes a horizontal lane, with
    each element drawn as a block spanning its longitudinal extent, colored
    by the method value.

    Parameters
    ----------
    data : ElementMethodsPlotData
        Per-element method data, gathered via
        `ElementMethodsPlotData.from_tao`.
    columns : sequence of str, optional
        Method columns to plot, in order.  Defaults to all categorical
        columns with data for the selected elements.
    show_names : bool, default=True
        Label method transitions with the element names before and after
        the transition point.
    show_csr_ds_step : bool, optional
        Add a subplot of `csr_ds_step` vs s.  The default (`None`) shows
        it only when CSR is active for at least one selected element.
    include_layout : bool, default=True
        Include a lattice layout plot at the bottom.
    lane_height : float, default=0.8
        Height of each lane's blocks, where lanes are spaced 1.0 apart.
    width : int, optional
        Width of each plot in pixels.
    height : int, optional
        Height of the lane plot in pixels.  Defaults to scaling with the
        number of lanes.
    layout_height : int, optional
        Height of the layout plot in pixels.
    save : pathlib.Path or str, optional
        Save the plot to the given filename.

    Returns
    -------
    ElementMethodsPlotData
    bokeh.layouts.column
    """
    columns = data.validate_columns(columns)

    if show_csr_ds_step is None:
        show_csr_ds_step = data.csr_on

    lanes_fig = figure(
        tools=_Defaults.tools,
        toolbar_location="above",
        x_range=bokeh.models.Range1d(min(data.s_start), max(data.s_end)),
    )
    lane_renderers = _draw_method_lanes(data, columns, lanes_fig, lane_height)
    if show_names:
        _draw_method_transition_names(data, columns, lanes_fig)
    _draw_method_legend(lanes_fig, lane_renderers)
    lanes_fig.frame_height = height or max(150, 32 * len(columns))

    figs = [lanes_fig]
    if show_csr_ds_step:
        csr_fig = figure(tools=lanes_fig.tools, toolbar_location=None)
        _draw_csr_ds_step(data, csr_fig)
        csr_fig.frame_height = 120
        figs.append(csr_fig)

    if include_layout:
        layout_fig = BokehLatticeLayoutGraph(
            self, self.lattice_layout_graph
        ).create_figure(toolbar_location=None)
        layout_fig.frame_height = layout_height or _Defaults.layout_height
        figs.append(layout_fig)

    min_border_left = max(80, 8 * max(len(col) for col in columns) + 24)
    for fig in figs:
        fig.frame_width = width or _Defaults.width
        fig.min_border_left = min_border_left

    share_x_axes(figs)
    figs[-1].xaxis.axis_label = "s (m)"

    ui = bokeh.layouts.column(
        [
            lanes_fig,
            _method_settings_caption(data, margin_left=min_border_left),
            *figs[1:],
        ]
    )

    if save:
        if save is True:
            save = "ele_methods.html"
        filename = save_plot(ui, filename=save)
        logger.info(f"Saving plot to {filename!r}")

    return data, ui
pytao.plotting.bokeh.BokehGraphManager.plot_field
plot_field(ele_id, *, colormap=None, radius=0.015, num_points=100, x_scale=1.0, width=None, height=None, save=None)

Plot field information for a given element.

Parameters:

Name Type Description Default
ele_id str

Element ID.

required
colormap str

Colormap for the plot. Matplotlib defaults to "PRGn_r", and bokeh defaults to "".

None
radius float

Radius.

0.015
num_points int

Number of data points.

100
width int
None
height int
None
save Path or str

Save the plot to the given filename.

None

Returns:

Type Description
ElementField
figure
Source code in pytao/plotting/bokeh.py
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
def plot_field(
    self,
    ele_id: str,
    *,
    colormap: str | None = None,
    radius: float = 0.015,
    num_points: int = 100,
    x_scale: float = 1.0,
    width: int | None = None,
    height: int | None = None,
    save: bool | str | pathlib.Path | None = None,
):
    """
    Plot field information for a given element.

    Parameters
    ----------
    ele_id : str
        Element ID.
    colormap : str, optional
        Colormap for the plot.
        Matplotlib defaults to "PRGn_r", and bokeh defaults to "".
    radius : float, default=0.015
        Radius.
    num_points : int, default=100
        Number of data points.
    width : int, optional
    height : int, optional
    save : pathlib.Path or str, optional
        Save the plot to the given filename.

    Returns
    -------
    ElementField

    figure
    """
    field = ElementField.from_tao(self.tao, ele_id, num_points=num_points, radius=radius)
    fig = figure(title=f"Field of {ele_id}")

    palette = colormap or _Defaults.palette

    source = _fields_to_data_source([field], x_scale=x_scale)
    cmap = bokeh.models.LinearColorMapper(
        palette=palette or _Defaults.palette,
        low=np.min(source.data["by"]),
        high=np.max(source.data["by"]),
    )

    fig.image(
        image="by",
        x="x",
        y=-1,
        dw="dw",
        dh="dh",
        color_mapper=cmap,
        source=source,
        name="field_images",
    )
    color_bar = bokeh.models.ColorBar(color_mapper=cmap, location=(0, 0))
    fig.add_layout(color_bar, "right")

    fig.frame_width = width or _Defaults.width
    fig.frame_height = height or _Defaults.height

    if save:
        if save is True:
            save = f"{ele_id}_field"
        filename = save_plot(fig, filename=save)
        logger.info(f"Saving plot to {filename!r}")

    return field, fig
pytao.plotting.bokeh.BokehGraphManager.plot_grid
plot_grid(templates, grid, *, include_layout=False, share_x=None, width=None, height=None, figsize=None, layout_height=None, xlim=None, ylim=None, curves=None, settings=None, save=None, ix_uni=None)

Plot graphs on a grid with Bokeh.

Parameters:

Name Type Description Default
templates list of str

Graph template names.

required
grid (nrows, ncols)

Grid the provided graphs into this many rows and columns.

required
include_layout bool

Include a layout plot at the bottom of each column.

False
share_x bool or None

Share x-axes where sensible (None) or force sharing x-axes (True) for all plots.

None
figsize (int, int)

Figure size. Alternative to specifying width and height separately. This takes precedence over width and height.

None
width int

Width of the whole plot.

None
height int

Height of the whole plot.

None
layout_height int

Height of the layout plot.

None
xlim list of (float, float)

X axis limits for each graph.

None
ylim list of (float, float)

Y axis limits for each graph.

None
curves list of Dict[int, TaoCurveSettings]

One dictionary per graph, with each dictionary mapping the curve index to curve settings. These settings will be applied to the placed graphs prior to plotting.

None
settings list of TaoGraphSettings

Graph customization settings, per graph.

None
save Path or str

Save the plot to the given filename.

None
ix_uni int

Plot data from this universe for every graph in the grid.

None

Returns:

Type Description
list of graphs
BokehAppCreator
Source code in pytao/plotting/bokeh.py
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
def plot_grid(
    self,
    templates: list[str],
    grid: tuple[int, int],
    *,
    include_layout: bool = False,
    share_x: bool | None = None,
    width: int | None = None,
    height: int | None = None,
    figsize: tuple[int, int] | None = None,
    layout_height: int | None = None,
    xlim: OptionalLimit | Sequence[OptionalLimit] = None,
    ylim: OptionalLimit | Sequence[OptionalLimit] = None,
    curves: list[CurveIndexToCurve] | None = None,
    settings: list[TaoGraphSettings] | None = None,
    save: bool | str | pathlib.Path | None = None,
    ix_uni: int | None = None,
):
    """
    Plot graphs on a grid with Bokeh.

    Parameters
    ----------
    templates : list of str
        Graph template names.
    grid : (nrows, ncols), optional
        Grid the provided graphs into this many rows and columns.
    include_layout : bool, default=False
        Include a layout plot at the bottom of each column.
    share_x : bool or None, default=None
        Share x-axes where sensible (`None`) or force sharing x-axes (True)
        for all plots.
    figsize : (int, int), optional
        Figure size. Alternative to specifying `width` and `height`
        separately.  This takes precedence over `width` and `height`.
    width : int, optional
        Width of the whole plot.
    height : int, optional
        Height of the whole plot.
    layout_height : int, optional
        Height of the layout plot.
    xlim : list of (float, float), optional
        X axis limits for each graph.
    ylim : list of (float, float), optional
        Y axis limits for each graph.
    curves : list of Dict[int, TaoCurveSettings], optional
        One dictionary per graph, with each dictionary mapping the curve
        index to curve settings. These settings will be applied to the
        placed graphs prior to plotting.
    settings : list of TaoGraphSettings, optional
        Graph customization settings, per graph.
    save : pathlib.Path or str, optional
        Save the plot to the given filename.
    ix_uni : int, optional
        Plot data from this universe for every graph in the grid.

    Returns
    -------
    list of graphs

    BokehAppCreator
    """
    graphs = self.prepare_grid_by_names(
        template_names=templates,
        curves=curves,
        settings=settings,
        xlim=xlim,
        ylim=ylim,
        ix_uni=ix_uni,
    )

    if figsize is not None:
        width, height = figsize

    app = BokehAppCreator(
        manager=self,
        graphs=graphs,
        share_x=share_x,
        include_variables=False,
        grid=grid,
        width=width or _Defaults.width,
        height=height or _Defaults.stacked_height,
        layout_height=layout_height or _Defaults.layout_height,
        include_layout=include_layout,
        xlim=xlim,
        ylim=ylim,
        ix_uni=ix_uni,
    )

    if save:
        if save is True:
            save = ""
        filename = app.save(save)
        logger.info(f"Saving plot to {filename!r}")
    return graphs, app
pytao.plotting.bokeh.BokehGraphManager.to_bokeh_graph
to_bokeh_graph(graph)

Create a Bokeh graph instance from the backend-agnostic AnyGraph version.

For example, BasicGraph becomes BokehBasicGraph.

Parameters:

Name Type Description Default
graph AnyGraph
required

Returns:

Type Description
AnyBokehGraph
Source code in pytao/plotting/bokeh.py
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
def to_bokeh_graph(self, graph: AnyGraph) -> AnyBokehGraph:
    """
    Create a Bokeh graph instance from the backend-agnostic AnyGraph version.

    For example, `BasicGraph` becomes `BokehBasicGraph`.

    Parameters
    ----------
    graph : AnyGraph

    Returns
    -------
    AnyBokehGraph
    """
    if isinstance(graph, BasicGraph):
        return BokehBasicGraph(self, graph)
    elif isinstance(graph, LatticeLayoutGraph):
        return BokehLatticeLayoutGraph(self, graph)
    elif isinstance(graph, FloorPlanGraph):
        return BokehFloorPlanGraph(self, graph)
    raise NotImplementedError(type(graph).__name__)
pytao.plotting.bokeh.NotebookGraphManager
NotebookGraphManager(tao)

Bases: BokehGraphManager

Jupyter notebook Bokeh backend graph manager.

Source code in pytao/plotting/plot.py
1406
1407
1408
1409
def __init__(self, tao: Tao) -> None:
    self.tao = tao
    self.regions = {}
    self._to_place = {}
Methods:
pytao.plotting.bokeh.NotebookGraphManager.plot
plot(template, *, region_name=None, include_layout=True, sizing_mode=None, width=None, height=None, layout_height=None, share_x=None, vars=False, xlim=None, ylim=None, notebook_handle=False, save=None, curves=None, settings=None, ix_uni=None)

Plot a graph with Bokeh.

Parameters:

Name Type Description Default
template str

Graph template name.

required
region_name str

Graph region name.

None
include_layout bool

Include a layout plot at the bottom, if not already placed and if appropriate (i.e., another plot uses longitudinal coordinates on the x-axis).

True
sizing_mode Optional[SizingModeType]

Set the sizing mode for all graphs. Default is configured on a per-graph basis, typically "inherit".

None
width int

Width of each plot.

None
height int

Height of each plot.

None
layout_height int

Height of the layout plot.

None
share_x bool or None

Share x-axes where sensible (None) or force sharing x-axes (True) for all plots.

None
vars bool

Show Tao variables as adjustable widgets, like "single mode".

False
xlim (float, float)

X axis limits.

None
ylim (float, float)

Y axis limits.

None
curves Dict[int, TaoCurveSettings]

Dictionary of curve index to curve settings. These settings will be applied to the placed graph prior to plotting.

None
settings TaoGraphSettings

Graph customization settings.

None
save str or bool

Save the plot to a static HTML file with the given name. If True, saves to a filename based on the plot title.

None
ix_uni int

Plot data from this universe.

None

Returns:

Type Description
BokehAppCreator
Source code in pytao/plotting/bokeh.py
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
def plot(
    self,
    template: str,
    *,
    region_name: str | None = None,
    include_layout: bool = True,
    sizing_mode: SizingModeType | None = None,
    width: int | None = None,
    height: int | None = None,
    layout_height: int | None = None,
    share_x: bool | None = None,
    vars: bool = False,
    xlim: Limit | None = None,
    ylim: Limit | None = None,
    notebook_handle: bool = False,
    save: bool | str | pathlib.Path | None = None,
    curves: dict[int, TaoCurveSettings] | None = None,
    settings: TaoGraphSettings | None = None,
    ix_uni: int | None = None,
) -> tuple[list[AnyGraph], BokehAppCreator]:
    """
    Plot a graph with Bokeh.

    Parameters
    ----------
    template : str
        Graph template name.
    region_name : str, optional
        Graph region name.
    include_layout : bool
        Include a layout plot at the bottom, if not already placed and if
        appropriate (i.e., another plot uses longitudinal coordinates on
        the x-axis).
    sizing_mode : Optional[SizingModeType]
        Set the sizing mode for all graphs.  Default is configured on a
        per-graph basis, typically "inherit".
    width : int, optional
        Width of each plot.
    height : int, optional
        Height of each plot.
    layout_height : int, optional
        Height of the layout plot.
    share_x : bool or None, default=None
        Share x-axes where sensible (`None`) or force sharing x-axes (True)
        for all plots.
    vars : bool, default=False
        Show Tao variables as adjustable widgets, like "single mode".
    xlim : (float, float), optional
        X axis limits.
    ylim : (float, float), optional
        Y axis limits.
    curves : Dict[int, TaoCurveSettings], optional
        Dictionary of curve index to curve settings. These settings will be
        applied to the placed graph prior to plotting.
    settings : TaoGraphSettings, optional
        Graph customization settings.
    save : str or bool, optional
        Save the plot to a static HTML file with the given name.
        If `True`, saves to a filename based on the plot title.
    ix_uni : int, optional
        Plot data from this universe.

    Returns
    -------
    BokehAppCreator
    """
    graphs, app = super().plot(
        region_name=region_name,
        template=template,
        include_layout=include_layout,
        sizing_mode=sizing_mode,
        width=width,
        height=height,
        layout_height=layout_height,
        xlim=xlim,
        ylim=ylim,
        curves=curves,
        settings=settings,
        share_x=share_x,
        ix_uni=ix_uni,
        save=save,
    )

    if vars:
        app.variables = Variable.from_tao_all(self.tao)

    bokeh.plotting.show(
        app.create_full_app(),
        notebook_handle=notebook_handle,
    )
    return graphs, app
pytao.plotting.bokeh.NotebookGraphManager.plot_field
plot_field(ele_id, *, colormap=None, radius=0.015, num_points=100, width=None, height=None, x_scale=1.0, save=None)

Plot field information for a given element.

Parameters:

Name Type Description Default
ele_id str

Element ID.

required
colormap str

Colormap for the plot. Matplotlib defaults to "PRGn_r", and bokeh defaults to "".

None
radius float

Radius.

0.015
num_points int

Number of data points.

100
width int
None
height int
None
save Path or str

Save the plot to the given filename.

None
Source code in pytao/plotting/bokeh.py
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
def plot_field(
    self,
    ele_id: str,
    *,
    colormap: str | None = None,
    radius: float = 0.015,
    num_points: int = 100,
    width: int | None = None,
    height: int | None = None,
    x_scale: float = 1.0,
    save: bool | str | pathlib.Path | None = None,
):
    """
    Plot field information for a given element.

    Parameters
    ----------
    ele_id : str
        Element ID.
    colormap : str, optional
        Colormap for the plot.
        Matplotlib defaults to "PRGn_r", and bokeh defaults to "".
    radius : float, default=0.015
        Radius.
    num_points : int, default=100
        Number of data points.
    width : int, optional
    height : int, optional
    save : pathlib.Path or str, optional
        Save the plot to the given filename.
    """
    field, fig = super().plot_field(
        ele_id,
        colormap=colormap,
        radius=radius,
        num_points=num_points,
        width=width,
        height=height,
        save=save,
        x_scale=x_scale,
    )
    bokeh.plotting.show(fig, notebook_handle=True)

    return field, fig
pytao.plotting.bokeh.NotebookGraphManager.plot_grid
plot_grid(templates, grid, *, curves=None, settings=None, include_layout=False, share_x=None, vars=False, figsize=None, layout_height=None, xlim=None, ylim=None, width=None, height=None, save=None, ix_uni=None)

Plot graphs on a grid with Bokeh.

Parameters:

Name Type Description Default
templates list of str

Graph template names.

required
grid (nrows, ncols)

Grid the provided graphs into this many rows and columns.

required
include_layout bool

Include a layout plot at the bottom of each column.

False
share_x bool or None

Share x-axes where sensible (None) or force sharing x-axes (True) for all plots.

None
vars bool

Show Tao variables as adjustable widgets, like "single mode".

False
figsize (int, int)

Figure size. Alternative to specifying width and height separately. This takes precedence over width and height.

None
width int

Width of the whole plot.

None
height int

Height of the whole plot.

None
layout_height int

Height of the layout plot.

None
xlim list of (float, float)

X axis limits for each graph.

None
ylim list of (float, float)

Y axis limits for each graph.

None
curves list of Dict[int, TaoCurveSettings]

One dictionary per graph, with each dictionary mapping the curve index to curve settings. These settings will be applied to the placed graphs prior to plotting.

None
settings list of TaoGraphSettings

Graph customization settings, per graph.

None
save Path or str

Save the plot to the given filename.

None
ix_uni int

Plot data from this universe for every graph in the grid.

None

Returns:

Type Description
list of graphs
BokehAppCreator
Source code in pytao/plotting/bokeh.py
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
def plot_grid(
    self,
    templates: list[str],
    grid: tuple[int, int],
    *,
    curves: list[CurveIndexToCurve] | None = None,
    settings: list[TaoGraphSettings] | None = None,
    include_layout: bool = False,
    share_x: bool | None = None,
    vars: bool = False,
    figsize: tuple[int, int] | None = None,
    layout_height: int | None = None,
    xlim: OptionalLimit | Sequence[OptionalLimit] = None,
    ylim: OptionalLimit | Sequence[OptionalLimit] = None,
    width: int | None = None,
    height: int | None = None,
    save: bool | str | pathlib.Path | None = None,
    ix_uni: int | None = None,
):
    """
    Plot graphs on a grid with Bokeh.

    Parameters
    ----------
    templates : list of str
        Graph template names.
    grid : (nrows, ncols), optional
        Grid the provided graphs into this many rows and columns.
    include_layout : bool, default=False
        Include a layout plot at the bottom of each column.
    share_x : bool or None, default=None
        Share x-axes where sensible (`None`) or force sharing x-axes (True)
        for all plots.
    vars : bool, default=False
        Show Tao variables as adjustable widgets, like "single mode".
    figsize : (int, int), optional
        Figure size. Alternative to specifying `width` and `height`
        separately.  This takes precedence over `width` and `height`.
    width : int, optional
        Width of the whole plot.
    height : int, optional
        Height of the whole plot.
    layout_height : int, optional
        Height of the layout plot.
    xlim : list of (float, float), optional
        X axis limits for each graph.
    ylim : list of (float, float), optional
        Y axis limits for each graph.
    curves : list of Dict[int, TaoCurveSettings], optional
        One dictionary per graph, with each dictionary mapping the curve
        index to curve settings. These settings will be applied to the
        placed graphs prior to plotting.
    settings : list of TaoGraphSettings, optional
        Graph customization settings, per graph.
    save : pathlib.Path or str, optional
        Save the plot to the given filename.
    ix_uni : int, optional
        Plot data from this universe for every graph in the grid.

    Returns
    -------
    list of graphs

    BokehAppCreator
    """
    graphs, app = super().plot_grid(
        templates=templates,
        grid=grid,
        curves=curves,
        settings=settings,
        include_layout=include_layout,
        share_x=share_x,
        figsize=figsize,
        width=width,
        height=height,
        xlim=xlim,
        ylim=ylim,
        layout_height=layout_height,
        save=save,
        ix_uni=ix_uni,
    )
    if vars:
        app.variables = Variable.from_tao_all(self.tao)
    bokeh.plotting.show(app.create_full_app())
    return graphs, app

Functions:

pytao.plotting.bokeh.floor_plan_figure
floor_plan_figure(elements, *, tools=None, toolbar_location='above', title='', x_axis_label='', y_axis_label='', sizing_mode='inherit', width=None, height=None, line_width_scale=None, annotate_elements=None)

Create a figure of floor plan elements, as Tao draws a floor_plan graph.

Parameters:

Name Type Description Default
elements sequence of FloorPlanElement
required
tools str

Bokeh tools string. Defaults to the floor plan tools setting.

None
toolbar_location str
"above"
title str
""
x_axis_label str
""
y_axis_label str
""
sizing_mode SizingModeType
"inherit"
width int
None
height int
None
line_width_scale float
None
annotate_elements bool

Draw element name labels. Defaults to the floor plan annotation setting.

None

Returns:

Type Description
figure
Source code in pytao/plotting/bokeh.py
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
def floor_plan_figure(
    elements: Sequence[FloorPlanElement],
    *,
    tools: str | None = None,
    toolbar_location: str = "above",
    title: str = "",
    x_axis_label: str = "",
    y_axis_label: str = "",
    sizing_mode: SizingModeType = "inherit",
    width: int | None = None,
    height: int | None = None,
    line_width_scale: float | None = None,
    annotate_elements: bool | None = None,
) -> figure:
    """
    Create a figure of floor plan elements, as Tao draws a `floor_plan` graph.

    Parameters
    ----------
    elements : sequence of FloorPlanElement
    tools : str, optional
        Bokeh tools string.  Defaults to the floor plan tools setting.
    toolbar_location : str, default="above"
    title : str, default=""
    x_axis_label, y_axis_label : str, default=""
    sizing_mode : SizingModeType, default="inherit"
    width, height : int, optional
    line_width_scale : float, optional
    annotate_elements : bool, optional
        Draw element name labels.  Defaults to the floor plan annotation setting.

    Returns
    -------
    bokeh.plotting.figure
    """
    if tools is None:
        tools = _Defaults.floor_plan_tools
    if line_width_scale is None:
        line_width_scale = _Defaults.floor_line_width_scale
    if annotate_elements is None:
        annotate_elements = _Defaults.floor_plan_annotate_elements

    add_named_hover_tool = isinstance(tools, str) and "hover" in tools.split(",")
    if add_named_hover_tool:
        tools = ",".join(tool for tool in tools.split(",") if tool != "hover")

    fig = figure(
        title=pgplot.mathjax_string(title),
        x_axis_label=pgplot.mathjax_string(x_axis_label),
        y_axis_label=pgplot.mathjax_string(y_axis_label),
        toolbar_location=toolbar_location,
        tools=tools,
        sizing_mode=sizing_mode,
        width=width,
        height=height,
        # This is vitally important for glyphs to render properly.
        # Compare how a circle centered at (0, 0) with a radius 1
        # looks with/without this setting
        match_aspect=True,
    )

    box_zoom = get_tool_from_figure(fig, bokeh.models.BoxZoomTool)
    if box_zoom is not None:
        box_zoom.match_aspect = True

    _draw_floor_plan_shapes(fig, list(elements), line_width_scale=line_width_scale)

    if add_named_hover_tool:
        hover = bokeh.models.HoverTool(
            renderers=get_hoverable_renderers(fig),
            tooltips=[("name", "@name")],
        )
        fig.add_tools(hover)

    if annotate_elements:
        _draw_annotations(
            fig,
            {elem.name: elem.annotations for elem in elements},
            font_size=_Defaults.floor_plan_font_size,
            skip_labels=False,
        )
    return fig
pytao.plotting.bokeh.lat_layout_figure
lat_layout_figure(elements, *, tools=None, toolbar_location='above', title='', x_axis_label='', sizing_mode='inherit', aspect_ratio=None, width=None, height=None, line_width_scale=None)

Create a figure of lattice layout elements, as Tao draws a lat_layout graph.

Parameters:

Name Type Description Default
elements sequence of LatticeLayoutElement
required
tools str

Bokeh tools string. Defaults to the lattice layout tools setting.

None
toolbar_location str
"above"
title str
""
x_axis_label str
""
sizing_mode SizingModeType
"inherit"
aspect_ratio float

Width / height.

None
width int
None
height int
None
line_width_scale float
None

Returns:

Type Description
figure
Source code in pytao/plotting/bokeh.py
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
def lat_layout_figure(
    elements: Sequence[LatticeLayoutElement],
    *,
    tools: str | None = None,
    toolbar_location: LocationType = "above",
    title: str = "",
    x_axis_label: str = "",
    sizing_mode: SizingModeType = "inherit",
    aspect_ratio: float | None = None,
    width: int | None = None,
    height: int | None = None,
    line_width_scale: float | None = None,
) -> figure:
    """
    Create a figure of lattice layout elements, as Tao draws a `lat_layout` graph.

    Parameters
    ----------
    elements : sequence of LatticeLayoutElement
    tools : str, optional
        Bokeh tools string.  Defaults to the lattice layout tools setting.
    toolbar_location : str, default="above"
    title : str, default=""
    x_axis_label : str, default=""
    sizing_mode : SizingModeType, default="inherit"
    aspect_ratio : float, optional
        Width / height.
    width, height : int, optional
    line_width_scale : float, optional

    Returns
    -------
    bokeh.plotting.figure
    """
    if tools is None:
        tools = _Defaults.lattice_layout_tools
    if line_width_scale is None:
        line_width_scale = _Defaults.line_width_scale

    add_named_hover_tool = isinstance(tools, str) and "hover" in tools.split(",")
    if add_named_hover_tool:
        tools = ",".join(tool for tool in tools.split(",") if tool != "hover")

    fig = figure(
        title=pgplot.mathjax_string(title),
        x_axis_label=pgplot.mathjax_string(x_axis_label),
        toolbar_location=toolbar_location,
        tools=tools,
        aspect_ratio=aspect_ratio,
        sizing_mode=sizing_mode,
        width=width,
        height=height,
    )

    box_zoom = get_tool_from_figure(fig, bokeh.models.BoxZoomTool)
    if box_zoom is not None:
        box_zoom.match_aspect = False

    fig.xaxis.ticker = bokeh.models.FixedTicker(
        ticks=[elem.info["ele_s_start"] for elem in elements],
        minor_ticks=[elem.info["ele_s_end"] for elem in elements],
    )
    fig.xaxis.major_label_overrides = {
        elem.info["ele_s_start"]: elem.info["label_name"] for elem in elements
    }
    fig.xaxis.major_label_orientation = math.pi / 4
    fig.yaxis.ticker = []
    fig.yaxis.visible = False

    _draw_layout_elems(
        fig, list(elements), skip_labels=True, line_width_scale=line_width_scale
    )

    if add_named_hover_tool:
        hover = bokeh.models.HoverTool(
            renderers=get_hoverable_renderers(fig),
            tooltips=[
                ("name", "@name"),
                ("s start (m)", "@s_start"),
                ("s end (m)", "@s_end"),
            ],
            mode="vline",
        )
        fig.add_tools(hover)

    fig.renderers.append(
        bokeh.models.Span(location=0, dimension="width", line_color="black", line_width=1)
    )
    return fig
pytao.plotting.bokeh.set_defaults
set_defaults(width=None, height=None, stacked_height=None, layout_height=None, palette=None, show_bokeh_logo=None, tools=None, grid_toolbar_location=None, lattice_layout_tools=None, floor_plan_tools=None, floor_plan_annotate_elements=None, layout_font_size=None, floor_plan_font_size=None, limit_scale_factor=None, max_data_points=None, variables_per_row=None, show_sliders=None, line_width_scale=None, floor_line_width_scale=None, resources=None)

Change defaults used for Bokeh plots.

Parameters:

Name Type Description Default
width int

Plot default width.

None
height int

Plot default height.

None
stacked_height int

Stacked plot default height (plot_grid)

None
layout_height int

Layout plot height.

None
palette str

Palette for plot_field.

None
show_bokeh_logo bool

Show Bokeh logo on each plot.

None
tools str

Bokeh tools to use.

"pan,wheel_zoom,box_zoom,reset,hover,crosshair"
grid_toolbar_location str

Toolbar location for gridded plots.

"right"
lattice_layout_tools str

Bokeh tools to use specifically for lattice layouts.

None
floor_plan_tools str

Bokeh tools to use specifically for floor plan layouts.

None
layout_font_size str

Font size to use in lattice layouts.

None
floor_plan_font_size str

Font size to use in floor plan layouts.

None
limit_scale_factor float

View limits from Tao are scaled by this factor. This can be used to ensure that all data is visible despite drawing method differences.

1.01
max_data_points int

Maximum number of data points to show in the slider.

None
variables_per_row int

Variables to list per row when in single mode (i.e., vars=True).

2
show_sliders bool

Show sliders alongside the spinners in single mode.

True
line_width_scale float

Plot line width scaling factor applied to Tao's line width.

1.0
floor_line_width_scale float

Floor plan line width scaling factor applied to Tao's line width.

0.5
resources 'cdn' or 'inline'

When saving Bokeh plots to HTML, make the file fully standalone ("inline") by saving everything necessary to load the page in the file, or retrieve shared scripts and resources from online ("cdn") when the page is opened.

None
Source code in pytao/plotting/bokeh.py
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
def set_defaults(
    width: int | None = None,
    height: int | None = None,
    stacked_height: int | None = None,
    layout_height: int | None = None,
    palette: str | None = None,
    show_bokeh_logo: bool | None = None,
    tools: str | None = None,
    grid_toolbar_location: str | None = None,
    lattice_layout_tools: str | None = None,
    floor_plan_tools: str | None = None,
    floor_plan_annotate_elements: bool | None = None,
    layout_font_size: str | None = None,
    floor_plan_font_size: str | None = None,
    limit_scale_factor: float | None = None,
    max_data_points: int | None = None,
    variables_per_row: int | None = None,
    show_sliders: bool | None = None,
    line_width_scale: float | None = None,
    floor_line_width_scale: float | None = None,
    resources: Literal["inline", "cdn"] | None = None,
):
    """
    Change defaults used for Bokeh plots.

    Parameters
    ----------
    width : int, optional
        Plot default width.
    height : int, optional
        Plot default height.
    stacked_height : int, optional
        Stacked plot default height (`plot_grid`)
    layout_height : int, optional
        Layout plot height.
    palette : str, optional
        Palette for `plot_field`.
    show_bokeh_logo : bool, optional
        Show Bokeh logo on each plot.
    tools : str, default="pan,wheel_zoom,box_zoom,reset,hover,crosshair"
        Bokeh tools to use.
    grid_toolbar_location : str, default="right"
        Toolbar location for gridded plots.
    lattice_layout_tools : str, optional
        Bokeh tools to use specifically for lattice layouts.
    floor_plan_tools : str, optional
        Bokeh tools to use specifically for floor plan layouts.
    layout_font_size : str, optional
        Font size to use in lattice layouts.
    floor_plan_font_size : str, optional
        Font size to use in floor plan layouts.
    limit_scale_factor : float, default=1.01
        View limits from Tao are scaled by this factor.  This can be used to
        ensure that all data is visible despite drawing method differences.
    max_data_points : int, optional
        Maximum number of data points to show in the slider.
    variables_per_row : int, default=2
        Variables to list per row when in single mode (i.e., `vars=True`).
    show_sliders : bool, default=True
        Show sliders alongside the spinners in single mode.
    line_width_scale : float, default=1.0
        Plot line width scaling factor applied to Tao's line width.
    floor_line_width_scale : float, default=0.5
        Floor plan line width scaling factor applied to Tao's line width.
    resources : "cdn" or "inline", optional
        When saving Bokeh plots to HTML, make the file fully standalone
        ("inline") by saving everything necessary to load the page in the file,
        or retrieve shared scripts and resources from online ("cdn") when
        the page is opened.
    """

    if width is not None:
        _Defaults.width = int(width)
    if height is not None:
        _Defaults.height = int(height)
    if stacked_height is not None:
        _Defaults.stacked_height = int(stacked_height)
    if layout_height is not None:
        _Defaults.layout_height = int(layout_height)
    if palette is not None:
        _Defaults.palette = palette
    if show_bokeh_logo is not None:
        _Defaults.show_bokeh_logo = bool(show_bokeh_logo)
    if tools is not None:
        _Defaults.tools = tools
    if grid_toolbar_location is not None:
        _Defaults.grid_toolbar_location = grid_toolbar_location
    if lattice_layout_tools is not None:
        _Defaults.lattice_layout_tools = lattice_layout_tools
    if floor_plan_tools is not None:
        _Defaults.floor_plan_tools = floor_plan_tools
    if floor_plan_annotate_elements is not None:
        _Defaults.floor_plan_annotate_elements = floor_plan_annotate_elements
    if layout_font_size is not None:
        _Defaults.layout_font_size = layout_font_size
    if floor_plan_font_size is not None:
        _Defaults.floor_plan_font_size = floor_plan_font_size
    if limit_scale_factor is not None:
        _Defaults.limit_scale_factor = float(limit_scale_factor)
    if max_data_points is not None:
        _Defaults.max_data_points = int(max_data_points)
    if variables_per_row is not None:
        _Defaults.variables_per_row = int(variables_per_row)
    if show_sliders is not None:
        _Defaults.show_sliders = bool(show_sliders)
    if line_width_scale is not None:
        _Defaults.line_width_scale = float(line_width_scale)
    if floor_line_width_scale is not None:
        _Defaults.floor_line_width_scale = float(floor_line_width_scale)
    if resources is not None:
        if resources not in ("cdn", "inline"):
            raise ValueError(f"Unexpected value for 'resources': {resources}")
        _Defaults.resources = resources
    return {
        key: value
        for key, value in vars(_Defaults).items()
        if not key.startswith("_") and key not in {"get_size_for_class"}
    }