bencher.results.bench_result_base ================================= .. py:module:: bencher.results.bench_result_base Classes ------- .. autoapisummary:: bencher.results.bench_result_base.ReduceType bencher.results.bench_result_base.EmptyContainer bencher.results.bench_result_base.BenchResultBase Functions --------- .. autoapisummary:: bencher.results.bench_result_base.convert_dataset_bool_dims_to_str Module Contents --------------- .. py:class:: ReduceType Bases: :py:obj:`enum.Enum` Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: AUTO .. py:attribute:: SQUEEZE .. py:attribute:: REDUCE .. py:attribute:: MINMAX .. py:attribute:: NONE .. py:class:: EmptyContainer(pane) A wrapper for list like containers that only appends if the item is not None .. py:attribute:: pane .. py:method:: append(child) .. py:method:: get() .. py:function:: convert_dataset_bool_dims_to_str(dataset: xarray.Dataset) -> xarray.Dataset Given a dataarray that contains boolean coordinates, convert them to strings so that holoviews loads the data properly :param dataarray: dataarray with boolean coordinates :type dataarray: xr.DataArray :returns: dataarray with boolean coordinates converted to strings :rtype: xr.DataArray .. py:class:: BenchResultBase(bench_cfg: bencher.bench_cfg.BenchCfg) .. py:attribute:: bench_cfg .. py:attribute:: ds .. py:attribute:: object_index :value: [] .. py:attribute:: hmaps .. py:attribute:: result_hmaps .. py:attribute:: studies :value: [] .. py:attribute:: plt_cnt_cfg .. py:attribute:: plot_inputs :value: [] .. py:attribute:: dataset_list :value: [] .. py:attribute:: regression_report :value: None .. py:attribute:: perf_report :value: None .. py:attribute:: _to_dataset_cache :type: dict .. py:method:: to_xarray() -> xarray.Dataset .. py:method:: setup_object_index() .. py:method:: to_pandas(reset_index=True) -> pandas.DataFrame Get the xarray results as a pandas dataframe :returns: The xarray results array as a pandas dataframe :rtype: pd.DataFrame .. py:method:: wrap_long_time_labels(bench_cfg) Takes a benchCfg and formats over_time coordinate labels for display. For discrete TimeEvent labels, wraps long strings for readability. For datetime TimeSnapshot labels, replaces with integer indices so that Panel renders a slider widget. Without this, Panel's DiscreteSlider truncates np.datetime64 values to second precision, which causes sub-second timestamps to collide into fewer slider positions. :param bench_cfg: :type bench_cfg: BenchCfg :returns: updated config with wrapped labels :rtype: BenchCfg .. py:method:: post_setup() .. py:method:: result_samples() -> int The number of samples in the results dataframe .. py:method:: to_hv_dataset(reduce: ReduceType = ReduceType.AUTO, result_var: bencher.variables.results.ResultFloat | None = None, subsampling_divisions: int | None = None, agg_over_dims: list[str] | None = None, agg_fn: Literal['mean', 'sum', 'max', 'min', 'median'] | None = None) -> holoviews.Dataset Generate a holoviews dataset from the xarray dataset. :param reduce: Optionally perform reduce options on the dataset. By default the returned dataset will calculate the mean and standard deviation over the "repeat" dimension so that the dataset plays nicely with most of the holoviews plot types. Reduce.Sqeeze is used if there is only 1 repeat and you want the "reduce" variable removed from the dataset. ReduceType.None returns an unaltered dataset. Defaults to ReduceType.AUTO. :type reduce: ReduceType, optional :returns: results in the form of a holoviews dataset :rtype: hv.Dataset .. py:method:: _resolve_auto(reduce: ReduceType) -> ReduceType Resolve AUTO to a concrete ReduceType based on repeat count. .. py:method:: _to_dataset_cache_key(reduce: ReduceType, result_var: bencher.variables.results.ResultFloat | str | None, subsampling_divisions: int | None, agg_over_dims: list[str] | None, agg_fn: str | None) -> tuple Build a hashable cache key from normalized to_dataset() arguments. .. py:method:: to_dataset(reduce: ReduceType = ReduceType.AUTO, result_var: bencher.variables.results.ResultFloat | str | None = None, subsampling_divisions: int | None = None, agg_over_dims: list[str] | None = None, agg_fn: Literal['mean', 'sum', 'max', 'min', 'median'] | None = None, deep: bool = True) -> xarray.Dataset Generate a summarised xarray dataset. :param reduce: Optionally perform reduce options on the dataset. By default the returned dataset will calculate the mean and standard deviation over the "repeat" dimension so that the dataset plays nicely with most of the holoviews plot types. Reduce.Sqeeze is used if there is only 1 repeat and you want the "reduce" variable removed from the dataset. ReduceType.None returns an unaltered dataset. Defaults to ReduceType.AUTO. :type reduce: ReduceType, optional :param deep: If True (default), return a deep copy that is safe to mutate. Pass False to get the cached object directly for read-only use (avoids the copy cost). :type deep: bool, optional :returns: results in the form of an xarray dataset :rtype: xr.Dataset .. note:: Results are computed once and cached per instance. By default (``deep=True``) a deep copy is returned so callers can safely mutate the result. Internal hot paths pass ``deep=False`` to reuse the cached object directly. .. py:method:: get_optimal_vec(result_var: bencher.variables.parametrised_sweep.ParametrizedSweep, input_vars: list[bencher.variables.parametrised_sweep.ParametrizedSweep]) -> list[Any] Get the optimal values from the sweep as a vector. :param result_var: Optimal values of this result variable :type result_var: bn.ParametrizedSweep :param input_vars: Define which input vars values are returned in the vector :type input_vars: list[bn.ParametrizedSweep] :returns: A vector of optimal values for the desired input vector :rtype: list[Any] .. py:method:: get_optimal_value_indices(result_var: bencher.variables.parametrised_sweep.ParametrizedSweep) -> xarray.DataArray Get an xarray mask of the values with the best values found during a parameter sweep :param result_var: Optimal value of this result variable :type result_var: bn.ParametrizedSweep :returns: xarray mask of optimal values :rtype: xr.DataArray .. py:method:: get_optimal_inputs(result_var: bencher.variables.parametrised_sweep.ParametrizedSweep, keep_existing_consts: bool = True, as_dict: bool = False) -> tuple[bencher.variables.parametrised_sweep.ParametrizedSweep, Any] | dict[bencher.variables.parametrised_sweep.ParametrizedSweep, Any] Get a list of tuples of optimal variable names and value pairs, that can be fed in as constant values to subsequent parameter sweeps :param result_var: Optimal values of this result variable :type result_var: bn.ParametrizedSweep :param keep_existing_consts: Include any const values that were defined as part of the parameter sweep :type keep_existing_consts: bool :param as_dict: return value as a dictionary :type as_dict: bool :returns: Tuples of variable name and optimal values :rtype: tuple[bn.ParametrizedSweep, Any]|[ParametrizedSweep, Any] .. py:method:: describe_sweep() .. py:method:: get_hmap(name: str | None = None) .. py:method:: to_plot_title() -> str .. py:method:: title_from_ds(dataset: xarray.Dataset, result_var: param.Parameter, **kwargs) .. py:method:: get_results_var_list(result_var: bencher.variables.parametrised_sweep.ParametrizedSweep | None = None) -> list[param.Parameter] .. py:method:: map_plots(plot_callback: Callable, result_var: bencher.variables.parametrised_sweep.ParametrizedSweep | None = None, row: EmptyContainer | None = None) -> panel.Row | None .. py:method:: zip_results1D(args) :staticmethod: .. py:method:: zip_results1D1(panel_list) :staticmethod: .. py:method:: zip_results1D2(panel_list) :staticmethod: .. py:method:: map_plot_panes(plot_callback: Callable, hv_dataset: holoviews.Dataset = None, target_dimension: int = 2, result_var: bencher.variables.results.ResultFloat | None = None, result_types=None, pane_collection: panel.pane = None, zip_results=False, reduce: ReduceType | None = None, pane_layout: bencher.results.composable_container.composable_container_base.PaneLayout = PaneLayout.grid, **kwargs) -> panel.Row | None .. py:method:: filter(plot_callback: Callable, plot_filter=None, float_range: bencher.plotting.plot_filter.VarRange | None = None, cat_range: bencher.plotting.plot_filter.VarRange | None = None, vector_len: bencher.plotting.plot_filter.VarRange | None = None, result_vars: bencher.plotting.plot_filter.VarRange | None = None, panel_range: bencher.plotting.plot_filter.VarRange | None = None, repeats_range: bencher.plotting.plot_filter.VarRange | None = None, input_range: bencher.plotting.plot_filter.VarRange | None = None, reduce: ReduceType = ReduceType.AUTO, target_dimension: int = 2, result_var: bencher.variables.results.ResultFloat | None = None, result_types=None, pane_collection: panel.pane = None, override=False, hv_dataset: holoviews.Dataset | None = None, agg_over_dims: list[str] | None = None, agg_fn: Literal['mean', 'sum', 'max', 'min', 'median'] = 'mean', pane_layout: bencher.results.composable_container.composable_container_base.PaneLayout = PaneLayout.grid, **kwargs) -> panel.panel | None .. py:method:: to_panes_multi_panel(hv_dataset: holoviews.Dataset, result_var: bencher.variables.results.ResultFloat, plot_callback: Callable | None = None, target_dimension: int = 1, pane_layout: bencher.results.composable_container.composable_container_base.PaneLayout = PaneLayout.grid, **kwargs) .. py:method:: _child_pane_layout(pane_layout: bencher.results.composable_container.composable_container_base.PaneLayout) -> bencher.results.composable_container.composable_container_base.PaneLayout :staticmethod: Return the layout to use for child dimensions during recursion. .. py:method:: _iter_pane_slices(dataset, selected_dim, plot_callback, target_dimension, result_var, child_layout) Yield (label_val, panes) for each slice along selected_dim. .. py:method:: _to_panes_da(dataset: xarray.Dataset, plot_callback: Callable | None = None, target_dimension=1, horizontal=False, result_var=None, pane_layout: bencher.results.composable_container.composable_container_base.PaneLayout = PaneLayout.grid, **kwargs) -> panel.panel .. py:method:: _pane_over_time_slider(dataset: xarray.Dataset, result_var) -> panel.Column Create a Panel slider widget for over_time with pane-type results. Numeric plot callbacks (line, heatmap) handle over_time internally via hv.HoloMap. Pane-type callbacks (images, videos, rerun) cannot use HoloMap because they produce Panel objects, not HoloViews elements. This method builds per-time-point content and swaps it via a Bokeh JS callback to avoid Panel's ImportedStyleSheet document-ownership errors. .. py:method:: _pane_over_time_grid(dataset: xarray.Dataset, result_var) -> panel.Row | panel.pane.Markdown Render over_time pane results as a grid of labelled panels. Used for ResultRerun because rerun iframes do not work inside a Bokeh JS slider swap (the viewer fails to re-initialise). .. py:method:: zero_dim_da_to_val(da_ds: xarray.DataArray | xarray.Dataset) -> Any .. py:method:: ds_to_container(dataset: xarray.Dataset, result_var: param.Parameter, container, **kwargs) -> Any .. py:method:: select_subsampling_divisions(dataset: xarray.Dataset, subsampling_divisions: int, include_types: list[type] | None = None, exclude_names: list[str] | None = None) -> xarray.Dataset :staticmethod: Given a dataset, return a reduced dataset that only contains data from a specified subsampling_divisions. By default all types of variables are filtered at the specified subsampling_divisions. If you only want to get a reduced subsampling_divisions for some types of data you can pass in a list of types to get filtered, You can also pass a list of variables names to exclude from getting filtered :param dataset: dataset to filter :type dataset: xr.Dataset :param subsampling_divisions: desired data resolution subsampling_divisions :type subsampling_divisions: int :param include_types: Only filter data of these types. Defaults to None. :type include_types: list[type], optional :param exclude_names: Only filter data with these variable names. Defaults to None. :type exclude_names: list[str], optional :returns: A reduced dataset at the specified subsampling_divisions :rtype: xr.Dataset Example: a dataset with float_var: [1,2,3,4,5] cat_var: [a,b,c,d,e] select_subsampling_divisions(ds,2) -> [1,5] [a,e] select_subsampling_divisions(ds,2,(float)) -> [1,5] [a,b,c,d,e] select_subsampling_divisions(ds,2,exclude_names=["cat_var]) -> [1,5] [a,b,c,d,e] see test_bench_result_base.py -> test_select_subsampling_divisions() .. py:method:: select_level(dataset: xarray.Dataset, level: int, include_types: list[type] | None = None, exclude_names: list[str] | None = None) -> xarray.Dataset :staticmethod: Deprecated: use :meth:`select_subsampling_divisions` instead. .. py:method:: to_sweep_summary(**kwargs) .. py:method:: to_title(panel_name: str | None = None) -> panel.pane.Markdown .. py:method:: to_description(width: int = 800) -> panel.pane.Markdown .. py:method:: set_plot_size(**kwargs) -> dict