bencher.results.composable_container.composable_container_base
Classes
A spatial composition direction -- the only thing that has an opposite. |
|
StrEnum is a Python |
|
Controls how multi-dimensional data is laid out in panel displays. |
|
A base class for renderer backends. A composable renderer |
Functions
|
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.StrEnumA spatial composition direction – the only thing that has an opposite.
ComposeTypehas 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, soflip()lives here rather than onComposeType: asking a non-spatial compose type for its opposite is now unrepresentable instead of aRuntimeErrorraised mid-render (plan 23 C6, phase P8).The member values match the corresponding
ComposeTypevalues, so anAxiscompares equal to theComposeTypeit maps to.- right
- down
- to_compose_type() ComposeType
Return the
ComposeTypethat composes along this axis.
- class bencher.results.composable_container.composable_container_base.ComposeType
Bases:
strenum.StrEnumStrEnum is a Python
enum.Enumthat inherits fromstr. The defaultauto()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.
sequenceandoverlayplace nothing beside anything, so they have no axis and nothing to flip – henceNonerather 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 raisedRuntimeErrorfromComposeType.flippartway through rendering.time_sequence_dimension (int, optional) – Compose dimensions up to this index in time rather than in space.
-1sequences 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.StrEnumControls 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