bencher.results.composable_container.composable_container_base

Classes

Axis

A spatial composition direction -- the only thing that has an opposite.

ComposeType

StrEnum is a Python enum.Enum that inherits from str. The default

PaneLayout

Controls how multi-dimensional data is laid out in panel displays.

ComposableContainerBase

A base class for renderer backends. A composable renderer

Functions

compose_method_list_for_dims(→ list[ComposeType])

Choose a composition method per dimension for a num_dims-dimensional sweep.

Module Contents

class bencher.results.composable_container.composable_container_base.Axis

Bases: strenum.StrEnum

A spatial composition direction – the only thing that has an opposite.

ComposeType has two members that say where the next container goes (right/down) and two that do not (sequence/overlay). Only the first pair can be flipped, so flip() lives here rather than on ComposeType: asking a non-spatial compose type for its opposite is now unrepresentable instead of a RuntimeError raised mid-render (plan 23 C6, phase P8).

The member values match the corresponding ComposeType values, so an Axis compares equal to the ComposeType it maps to.

right
down
flip() Axis

Return the other axis. Total by construction.

to_compose_type() ComposeType

Return the ComposeType that composes along this axis.

static from_horizontal(horizontal: bool) Axis
class bencher.results.composable_container.composable_container_base.ComposeType

Bases: strenum.StrEnum

StrEnum is a Python enum.Enum that inherits from str. The default auto() behavior uses the member name as its value.

Example usage:

class Example(StrEnum):
    UPPER_CASE = auto()
    lower_case = auto()
    MixedCase = auto()

assert Example.UPPER_CASE == "UPPER_CASE"
assert Example.lower_case == "lower_case"
assert Example.MixedCase == "MixedCase"
right
down
sequence
overlay
as_axis() Axis | None

The spatial axis this method composes along, or None if it has none.

sequence and overlay place nothing beside anything, so they have no axis and nothing to flip – hence None rather than a raise.

static from_horizontal(horizontal: bool) ComposeType
bencher.results.composable_container.composable_container_base.compose_method_list_for_dims(num_dims: int, first_compose_method: ComposeType | Axis = ComposeType.down, time_sequence_dimension: int = 0) list[ComposeType]

Choose a composition method per dimension for a num_dims-dimensional sweep.

By default the methods alternate between right and down (so nested dimensions stay readable) and a trailing sequence is appended for the level that varies fastest. Levels up to time_sequence_dimension are forced to sequence.

Parameters:
  • num_dims (int) – Number of dimensions being composed.

  • first_compose_method (ComposeType | Axis, optional) – Direction of the first composition. Defaults to ComposeType.down. A method with no axis (sequence/overlay) cannot alternate, so it is repeated on every spatial level instead; before plan 23 P8 that combination raised RuntimeError from ComposeType.flip partway through rendering.

  • time_sequence_dimension (int, optional) – Compose dimensions up to this index in time rather than in space. -1 sequences everything. Defaults to 0.

Returns:

One composition method per level, consumed from the end.

Return type:

list[ComposeType]

class bencher.results.composable_container.composable_container_base.PaneLayout

Bases: strenum.StrEnum

Controls how multi-dimensional data is laid out in panel displays.

grid: Use rows/columns for all dimensions (default, existing behavior) tabs: Use tabs for all outer dimensions, only the innermost uses grid tabs_and_grid: Use tabs for the outermost dimension, grid for inner dimensions

grid
tabs
tabs_and_grid
classmethod all() list[PaneLayout]

Return all layout values. Use this instead of hard-coded name lists.

class bencher.results.composable_container.composable_container_base.ComposableContainerBase

A base class for renderer backends. A composable renderer

compose_method: ComposeType
container: list[Any] = []
label_len: int = 0
static label_formatter(var_name: str | None, var_value: float | str | None) str | None

Take a variable name and values and return a pretty version with approximate fixed width

Parameters:
  • var_name (str | None) – The name of the variable, usually a dimension

  • var_value (int | float | str | None) – The value of the dimension

Returns:

Pretty string representation with fixed width, or None when

neither a name nor a value was given (every caller tests for None).

Return type:

str | None

append(obj: Any) None

Add an object to the container. The relationship between the objects is defined by the ComposeType

Parameters:

obj (Any) – Object to add to the container

render()

Return a representation of the container that can be composed with other render() results. This function can also be used to defer layout and rending options until all the information about the container content is known. You may need to override this method depending on the container. See composable_container_video as an example.

Returns:

Visual representation of the container that can be combined with other containers

Return type:

Any