Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 13 additions & 40 deletions bencher/results/holoview_results/curve_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,61 +11,37 @@


class CurveResult(HoloviewResult):
"""A class for creating curve plots from benchmark results.
"""A class for creating curve plots with optional standard-deviation spread.

Curve plots are useful for visualizing the relationship between a continuous
input variable and a result variable. This class provides methods to generate
line plots that can also display standard deviation bounds when benchmark runs
include multiple repetitions.
Curve plots show the relationship between a continuous input variable and a
result variable. When multiple benchmark repetitions are available, standard
deviation bounds are displayed using an ``hv.Spread`` overlay.
"""

def to_plot(
self, result_var: Parameter | None = None, override: bool = True, **kwargs
) -> hv.Curve | None:
"""Generates a curve plot from benchmark data.

This is a convenience method that calls to_curve() with the same parameters.

Args:
result_var (Parameter, optional): The result variable to plot. If None, uses the default.
override (bool, optional): Whether to override filter restrictions. Defaults to True.
**kwargs: Additional keyword arguments passed to the plot rendering.

Returns:
hv.Curve | None: A curve plot if data is appropriate,
otherwise returns filter match results.
"""
return self.to_curve(result_var=result_var, override=override, **kwargs)
def to_plot(self, **kwargs) -> hv.Curve | None:
"""Generates a curve plot. See ``to_curve`` for parameters."""
return self.to_curve(**kwargs)

def to_curve(
self,
result_var: Parameter | None = None,
override: bool = True,
target_dimension: int = 2,
**kwargs,
):
self, result_var: Parameter | None = None, override: bool = True, **kwargs
) -> hv.Curve | None:
"""Generates a curve plot from benchmark data.

This method applies filters to ensure the data is appropriate for a curve plot
and then passes the filtered data to to_curve_ds for rendering.

Args:
result_var (Parameter, optional): The result variable to plot. If None, uses the default.
result_var (Parameter, optional): The result variable to plot.
override (bool, optional): Whether to override filter restrictions. Defaults to True.
target_dimension (int, optional): The target dimensionality for data filtering. Defaults to 2.
**kwargs: Additional keyword arguments passed to the plot rendering.

Returns:
hv.Curve | None: A curve plot if data is appropriate,
otherwise returns filter match results.
hv.Curve | None: A curve plot, or filter match results.
"""
return self.filter(
self.to_curve_ds,
float_range=VarRange(1, 1),
cat_range=VarRange(0, None),
repeats_range=VarRange(2, None),
reduce=ReduceType.REDUCE,
target_dimension=target_dimension,
target_dimension=2,
result_var=result_var,
result_types=SCALAR_RESULT_TYPES,
override=override,
Expand All @@ -75,10 +51,7 @@ def to_curve(
def to_curve_ds(self, dataset: xr.Dataset, result_var: Parameter, **kwargs) -> hv.Curve | None:
"""Creates a curve plot from the provided dataset.

Given a filtered dataset, this method generates a curve visualization showing
the relationship between a continuous input variable and the result variable.
When multiple benchmark repetitions are available, standard deviation bounds
can also be displayed using a spread plot.
Generates a curve with optional standard deviation spread overlay.

When over_time is active with multiple time points, builds per-time-point
curves inside an hv.HoloMap so the slider controls the time dimension.
Expand Down
Loading
Loading