bencher.results.holoview_results.holoview_result
Attributes
Classes
Module Contents
- bencher.results.holoview_results.holoview_result.use_tap = True
- bencher.results.holoview_results.holoview_result._AGG_TITLE = 'All Time Points (aggregated)'
- class bencher.results.holoview_results.holoview_result.HoloviewResult(bench_cfg: bencher.bench_cfg.BenchCfg)
Bases:
bencher.results.pane_result.PaneResult- static set_default_opts(width: int = 600, height: int = 600) dict
Set default options for HoloViews visualizations.
- Parameters:
width (int, optional) – Default width for visualizations. Defaults to 600.
height (int, optional) – Default height for visualizations. Defaults to 600.
- Returns:
Dictionary containing width, height, and tools settings.
- Return type:
dict
- to_hv_type(hv_type: type, reduce: bencher.results.bench_result_base.ReduceType = ReduceType.AUTO, **kwargs) holoviews.Chart
Convert the dataset to a specific HoloViews visualization type.
- Parameters:
hv_type (type) – The HoloViews chart type to convert to (e.g., hv.Points, hv.Curve).
reduce (ReduceType, optional) – How to reduce dataset dimensions. Defaults to ReduceType.AUTO.
**kwargs – Additional parameters to pass to the chart constructor.
- Returns:
A HoloViews chart of the specified type.
- Return type:
hv.Chart
- overlay_plots(plot_callback: callable) holoviews.Overlay | panel.Row | None
Create an overlay of plots by applying a callback to each result variable.
- Parameters:
plot_callback (callable) – Function to apply to each result variable to create a plot.
- Returns:
An overlay of plots or Row of plots, or None if no results.
- Return type:
hv.Overlay | pn.Row | None
- layout_plots(plot_callback: callable) holoviews.Layout | None
Create a layout of plots by applying a callback to each result variable.
- Parameters:
plot_callback (callable) – Function to apply to each result variable to create a plot.
- Returns:
A layout of plots or None if no results.
- Return type:
hv.Layout | None
- time_widget(title: str) dict
Create widget configuration for time-based visualizations.
- Parameters:
title (str) – Title for the widget.
- Returns:
Widget configuration dictionary with title.
- Return type:
dict
- _use_holomap_for_time(dataset: xarray.Dataset) bool
Check whether over_time should be rendered via an hv.HoloMap slider.
Returns True when over_time is active and the dataset has >1 time points.
- static _apply_opts(plot, **opts_kwargs)
Apply .opts() to a plot, handling panel.pane.HoloViews wrappers.
When hvplot is called with widget_location, it returns a panel pane whose underlying .object is the actual holoviews element.
- static _over_time_kdims() list
Return the kdim list for over_time HoloMaps.
- static _holomap_with_slider_bottom(hvobj, widgets=None)
Wrap a HoloViews object so any scrubber/slider appears below the plot.
pn.pane.HoloViews(holomap, widget_location="bottom")does not embed correctly in static HTML (the widget is lost). Instead we let Panel auto-create the widget viapn.panel(hvobj)(which produces aRow(plot, widget_box)), then rearrange into aColumn(plot, widget_box)so the slider sits underneath.Force
DiscreteSliderfor the over_time dimension so that string-basedTimeEventcoordinates get a slider instead of the default dropdownSelectwidget.Safe to call on any HoloViews object; if no widgets are produced the original object is returned unchanged.
The slider defaults to the most recent (last) time point by setting the widget value in Python. Panel’s embed system computes JSON patches relative to this default, so every other position gets a valid patch and the last position is the initial state.
- _build_curve_overlay(dataset: xarray.Dataset, result_var: param.Parameter, **kwargs) holoviews.Overlay
Build a Curve (+ optional Spread) overlay for a single time slice or aggregated data.
When
_stdexists in the dataset the spread band is rendered automatically. This is used by both the curve renderer and the line renderer (for aggregated data that gained_stdfrom_mean_over_time).Performance: avoids
to_dataframe()when there are no categorical groupby dimensions by constructinghv.Datasetdirectly from the xarray Dataset. The heavier DataFrame path is only used when manual groupby is required.
- static _mean_over_time(dataset, result_var_name)
Average a dataset across all time points.
Always produces a
_stdvariable so that downstream renderers (e.g. curve spread, error bars) can visualise the aggregation uncertainty. When a per-time-point_stdalready exists the pooled standard deviation is computed via the law of total variance; otherwise the standard deviation of the means across time points is used.
- static subsample_indices(n, max_points)
Return evenly-spaced indices into a length-n array.
Always includes the first and last index. When max_points is
Noneor >= n, returnsrange(n)(no subsampling).
- _build_time_holomap(dataset, result_var_name, make_plot_fn)
Build per-time-point HoloMap + optional aggregated plot.
make_plot_fnreceives a Dataset without theover_timedimension. The aggregated dataset produced by_mean_over_timealways contains a_stdvariable; callbacks that are_std-aware (e.g. delegating to_build_curve_overlay) will automatically render spread bands on the aggregated tab.When
bench_cfg.max_slider_pointsis set, only that many evenly-spaced time points are rendered for the slider (first and last always included). The aggregated tab still uses all data.When
bench_cfg.show_aggregated_time_tabisFalse, the aggregation is skipped entirely for faster rendering.
- _build_time_holomap_raw(da, make_plot_fn)
Build per-time-point HoloMap + optional aggregated plot for distributions.
make_plot_fn receives a DataArray that retains the
over_timedimension (a single-element slice for per-time-point entries, or the full array for the aggregated tab). Callers should flatten via.to_dataframe().reset_index()or equivalent.Respects
bench_cfg.max_slider_pointsandbench_cfg.show_aggregated_time_tab.
- _build_tap_plot(plot: holoviews.Element, dataset: xarray.Dataset, result_var_plots: list[param.Parameter], container: type | list[type] | None = None, tap_container_direction: type | None = None) panel.Row
Wrap a plot element with interactive PointerXY tap functionality.
Sets up
hv.streams.PointerXYandhv.streams.MouseLeaveon the given plot, updating the supplied containers with the nearest data point values as the user hovers.- Parameters:
plot – The base HoloViews element to attach tap streams to.
dataset – The full xarray Dataset for value look-ups.
result_var_plots – Result variables whose values are shown on tap.
container – Panel container type(s) for displaying tapped values.
tap_container_direction – Layout class (
pn.Roworpn.Column) for the tap containers. Defaults topn.Column.
- Returns:
A
pn.Rowcontaining the interactive plot and tap info panel.
- hv_container_ds(dataset: xarray.Dataset, result_var: param.Parameter, container: holoviews.Chart | None = None, **kwargs) holoviews.Chart
Convert an xarray Dataset to a HoloViews container for a specific result variable.
- Parameters:
dataset (xr.Dataset) – The xarray Dataset containing the data.
result_var (Parameter) – The result variable to visualize.
container (hv.Chart, optional) – The HoloViews container type to use. Defaults to None.
**kwargs – Additional options to pass to the chart’s opts() method.
- Returns:
A HoloViews chart containing the visualization.
- Return type:
hv.Chart
- to_hv_container(container: panel.pane.panel, reduce_type: bencher.results.bench_result_base.ReduceType = ReduceType.AUTO, target_dimension: int = 2, result_var: param.Parameter | None = None, result_types: tuple | None = (ResultFloat,), **kwargs) panel.pane.panel | None
Convert the data to a HoloViews container with specified dimensions and options.
- Parameters:
container (pn.pane.panel) – The panel container type to use.
reduce_type (ReduceType, optional) – How to reduce the dataset dimensions. Defaults to ReduceType.AUTO.
target_dimension (int, optional) – Target dimension for the visualization. Defaults to 2.
result_var (Parameter, optional) – Specific result variable to visualize. Defaults to None.
result_types (tuple, optional) – Types of result variables to include. Defaults to (ResultFloat).
**kwargs – Additional visualization options.
- Returns:
A panel containing the visualization, or None if no valid results.
- Return type:
pn.pane.panel | None
- result_var_to_container(result_var: param.Parameter) type
Determine the appropriate container type for a given result variable.
- Parameters:
result_var (Parameter) – The result variable to find a container for.
- Returns:
The appropriate panel container type (PNG, Video, or Column).
- Return type:
type
- setup_results_and_containers(result_var_plots: param.Parameter | list[param.Parameter], container: type | list[type] | None = None, **kwargs) tuple[list[param.Parameter], list[panel.pane.panel]]
Set up appropriate containers for result variables.
- Parameters:
result_var_plots (Parameter | list[Parameter]) – Result variables to visualize.
container (type | list[type], optional) – Container types to use. Defaults to None.
**kwargs – Additional options to pass to the container constructors.
- Returns:
- Tuple containing:
List of result variables
List of initialized container instances
- Return type:
tuple[list[Parameter], list[pn.pane.panel]]
- to_error_bar(result_var: param.Parameter | str | None = None, **kwargs) holoviews.Bars
Convert the dataset to an ErrorBars visualization for a specific result variable.
- Parameters:
result_var (Parameter | str, optional) – Result variable to visualize. Defaults to None.
**kwargs – Additional options for dataset reduction.
- Returns:
A HoloViews ErrorBars object showing error ranges.
- Return type:
hv.Bars
- to_points(reduce: bencher.results.bench_result_base.ReduceType = ReduceType.AUTO) holoviews.Points
Convert the dataset to a Points visualization with optional error bars.
- Parameters:
reduce (ReduceType, optional) – How to reduce the dataset dimensions. Defaults to ReduceType.AUTO.
- Returns:
A HoloViews Points object, potentially with ErrorBars if reduction is applied.
- Return type:
hv.Points
- to_nd_layout(hmap_name: str) holoviews.NdLayout
Convert a HoloMap to an NdLayout for multi-dimensional visualization.
- Parameters:
hmap_name (str) – Name of the HoloMap to convert.
- Returns:
A HoloViews NdLayout object with the visualization.
- Return type:
hv.NdLayout
- to_holomap(name: str | None = None) holoviews.HoloMap
Convert an NdLayout to a HoloMap for animated/interactive visualization.
- Parameters:
name (str, optional) – Name of the HoloMap to use. Defaults to None.
- Returns:
A HoloViews HoloMap object with the visualization.
- Return type:
hv.HoloMap
- to_holomap_list(hmap_names: list[str] | None = None) panel.Column
Create a column of HoloMaps from multiple named maps.
- Parameters:
hmap_names (list[str], optional) – list of HoloMap names to include. If None, uses all result_hmaps. Defaults to None.
- Returns:
A panel Column containing multiple HoloMaps.
- Return type:
pn.Column
- get_nearest_holomap(name: str | None = None, **kwargs) holoviews.HoloMap
Get the HoloMap element closest to the specified coordinates.
- Parameters:
name (str, optional) – Name of the HoloMap to use. Defaults to None.
**kwargs – Coordinate values to find nearest match for.
- Returns:
The nearest matching HoloMap element.
- Return type:
hv.HoloMap
- to_dynamic_map(name: str | None = None) holoviews.DynamicMap
Create a DynamicMap from the HoloMap dictionary.
Uses the values stored in the holomap dictionary to populate a dynamic map. This is much faster than passing the holomap to a holomap object as the values are calculated on the fly.
- Parameters:
name (str, optional) – Name of the HoloMap to use. Defaults to None.
- Returns:
A HoloViews DynamicMap for interactive visualization.
- Return type:
hv.DynamicMap
- to_grid(inputs: list[str] | None = None) holoviews.GridSpace
Create a grid visualization from a HoloMap.
- Parameters:
inputs (list[str], optional) – Input variable names to use for the grid dimensions. If None, uses bench_cfg.inputs_as_str(). Defaults to None.
- Returns:
A HoloViews GridSpace object showing the data as a grid.
- Return type:
hv.GridSpace