bencher.results.holoview_results.holoview_result ================================================ .. py:module:: bencher.results.holoview_results.holoview_result Attributes ---------- .. autoapisummary:: bencher.results.holoview_results.holoview_result.use_tap bencher.results.holoview_results.holoview_result._AGG_TITLE Classes ------- .. autoapisummary:: bencher.results.holoview_results.holoview_result.HoloviewResult Module Contents --------------- .. py:data:: use_tap :value: True .. py:data:: _AGG_TITLE :value: 'All Time Points (aggregated)' .. py:class:: HoloviewResult(bench_cfg: bencher.bench_cfg.BenchCfg) Bases: :py:obj:`bencher.results.pane_result.PaneResult` .. py:method:: set_default_opts(width: int = 600, height: int = 600) -> dict :staticmethod: Set default options for HoloViews visualizations. :param width: Default width for visualizations. Defaults to 600. :type width: int, optional :param height: Default height for visualizations. Defaults to 600. :type height: int, optional :returns: Dictionary containing width, height, and tools settings. :rtype: dict .. py:method:: 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. :param hv_type: The HoloViews chart type to convert to (e.g., hv.Points, hv.Curve). :type hv_type: type :param reduce: How to reduce dataset dimensions. Defaults to ReduceType.AUTO. :type reduce: ReduceType, optional :param \*\*kwargs: Additional parameters to pass to the chart constructor. :returns: A HoloViews chart of the specified type. :rtype: hv.Chart .. py:method:: overlay_plots(plot_callback: callable) -> holoviews.Overlay | panel.Row | None Create an overlay of plots by applying a callback to each result variable. :param plot_callback: Function to apply to each result variable to create a plot. :type plot_callback: callable :returns: An overlay of plots or Row of plots, or None if no results. :rtype: hv.Overlay | pn.Row | None .. py:method:: layout_plots(plot_callback: callable) -> holoviews.Layout | None Create a layout of plots by applying a callback to each result variable. :param plot_callback: Function to apply to each result variable to create a plot. :type plot_callback: callable :returns: A layout of plots or None if no results. :rtype: hv.Layout | None .. py:method:: time_widget(title: str) -> dict Create widget configuration for time-based visualizations. :param title: Title for the widget. :type title: str :returns: Widget configuration dictionary with title. :rtype: dict .. py:method:: _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. .. py:method:: _apply_opts(plot, **opts_kwargs) :staticmethod: 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. .. py:method:: _over_time_kdims() -> list :staticmethod: Return the kdim list for over_time HoloMaps. .. py:method:: _holomap_with_slider_bottom(hvobj, widgets=None) :staticmethod: 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 via ``pn.panel(hvobj)`` (which produces a ``Row(plot, widget_box)``), then rearrange into a ``Column(plot, widget_box)`` so the slider sits underneath. Force ``DiscreteSlider`` for the *over_time* dimension so that string-based ``TimeEvent`` coordinates get a slider instead of the default dropdown ``Select`` widget. 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. .. py:method:: _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 ``_std`` exists 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 ``_std`` from ``_mean_over_time``). Performance: avoids ``to_dataframe()`` when there are no categorical groupby dimensions by constructing ``hv.Dataset`` directly from the xarray Dataset. The heavier DataFrame path is only used when manual groupby is required. .. py:method:: _mean_over_time(dataset, result_var_name) :staticmethod: Average a dataset across all time points. Always produces a ``_std`` variable so that downstream renderers (e.g. curve spread, error bars) can visualise the aggregation uncertainty. When a per-time-point ``_std`` already 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. .. py:method:: subsample_indices(n, max_points) :staticmethod: Return evenly-spaced indices into a length-*n* array. Always includes the first and last index. When *max_points* is ``None`` or >= *n*, returns ``range(n)`` (no subsampling). .. py:method:: _build_time_holomap(dataset, result_var_name, make_plot_fn) Build per-time-point HoloMap + optional aggregated plot. ``make_plot_fn`` receives a Dataset *without* the ``over_time`` dimension. The aggregated dataset produced by ``_mean_over_time`` always contains a ``_std`` variable; 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_points`` is 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_tab`` is ``False``, the aggregation is skipped entirely for faster rendering. .. py:method:: _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_time`` dimension (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_points`` and ``bench_cfg.show_aggregated_time_tab``. .. py:method:: _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.PointerXY`` and ``hv.streams.MouseLeave`` on the given *plot*, updating the supplied containers with the nearest data point values as the user hovers. :param plot: The base HoloViews element to attach tap streams to. :param dataset: The full xarray Dataset for value look-ups. :param result_var_plots: Result variables whose values are shown on tap. :param container: Panel container type(s) for displaying tapped values. :param tap_container_direction: Layout class (``pn.Row`` or ``pn.Column``) for the tap containers. Defaults to ``pn.Column``. :returns: A ``pn.Row`` containing the interactive plot and tap info panel. .. py:method:: 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. :param dataset: The xarray Dataset containing the data. :type dataset: xr.Dataset :param result_var: The result variable to visualize. :type result_var: Parameter :param container: The HoloViews container type to use. Defaults to None. :type container: hv.Chart, optional :param \*\*kwargs: Additional options to pass to the chart's opts() method. :returns: A HoloViews chart containing the visualization. :rtype: hv.Chart .. py:method:: 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. :param container: The panel container type to use. :type container: pn.pane.panel :param reduce_type: How to reduce the dataset dimensions. Defaults to ReduceType.AUTO. :type reduce_type: ReduceType, optional :param target_dimension: Target dimension for the visualization. Defaults to 2. :type target_dimension: int, optional :param result_var: Specific result variable to visualize. Defaults to None. :type result_var: Parameter, optional :param result_types: Types of result variables to include. Defaults to (ResultFloat). :type result_types: tuple, optional :param \*\*kwargs: Additional visualization options. :returns: A panel containing the visualization, or None if no valid results. :rtype: pn.pane.panel | None .. py:method:: result_var_to_container(result_var: param.Parameter) -> type Determine the appropriate container type for a given result variable. :param result_var: The result variable to find a container for. :type result_var: Parameter :returns: The appropriate panel container type (PNG, Video, or Column). :rtype: type .. py:method:: 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. :param result_var_plots: Result variables to visualize. :type result_var_plots: Parameter | list[Parameter] :param container: Container types to use. Defaults to None. :type container: type | list[type], optional :param \*\*kwargs: Additional options to pass to the container constructors. :returns: Tuple containing: - List of result variables - List of initialized container instances :rtype: tuple[list[Parameter], list[pn.pane.panel]] .. py:method:: 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. :param result_var: Result variable to visualize. Defaults to None. :type result_var: Parameter | str, optional :param \*\*kwargs: Additional options for dataset reduction. :returns: A HoloViews ErrorBars object showing error ranges. :rtype: hv.Bars .. py:method:: to_points(reduce: bencher.results.bench_result_base.ReduceType = ReduceType.AUTO) -> holoviews.Points Convert the dataset to a Points visualization with optional error bars. :param reduce: How to reduce the dataset dimensions. Defaults to ReduceType.AUTO. :type reduce: ReduceType, optional :returns: A HoloViews Points object, potentially with ErrorBars if reduction is applied. :rtype: hv.Points .. py:method:: to_nd_layout(hmap_name: str) -> holoviews.NdLayout Convert a HoloMap to an NdLayout for multi-dimensional visualization. :param hmap_name: Name of the HoloMap to convert. :type hmap_name: str :returns: A HoloViews NdLayout object with the visualization. :rtype: hv.NdLayout .. py:method:: to_holomap(name: str | None = None) -> holoviews.HoloMap Convert an NdLayout to a HoloMap for animated/interactive visualization. :param name: Name of the HoloMap to use. Defaults to None. :type name: str, optional :returns: A HoloViews HoloMap object with the visualization. :rtype: hv.HoloMap .. py:method:: to_holomap_list(hmap_names: list[str] | None = None) -> panel.Column Create a column of HoloMaps from multiple named maps. :param hmap_names: list of HoloMap names to include. If None, uses all result_hmaps. Defaults to None. :type hmap_names: list[str], optional :returns: A panel Column containing multiple HoloMaps. :rtype: pn.Column .. py:method:: get_nearest_holomap(name: str | None = None, **kwargs) -> holoviews.HoloMap Get the HoloMap element closest to the specified coordinates. :param name: Name of the HoloMap to use. Defaults to None. :type name: str, optional :param \*\*kwargs: Coordinate values to find nearest match for. :returns: The nearest matching HoloMap element. :rtype: hv.HoloMap .. py:method:: 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. :param name: Name of the HoloMap to use. Defaults to None. :type name: str, optional :returns: A HoloViews DynamicMap for interactive visualization. :rtype: hv.DynamicMap .. py:method:: to_grid(inputs: list[str] | None = None) -> holoviews.GridSpace Create a grid visualization from a HoloMap. :param inputs: Input variable names to use for the grid dimensions. If None, uses bench_cfg.inputs_as_str(). Defaults to None. :type inputs: list[str], optional :returns: A HoloViews GridSpace object showing the data as a grid. :rtype: hv.GridSpace