diff --git a/bencher/example/example_meta.py b/bencher/example/meta/example_meta.py similarity index 94% rename from bencher/example/example_meta.py rename to bencher/example/meta/example_meta.py index e941b79c..d89d3ada 100644 --- a/bencher/example/example_meta.py +++ b/bencher/example/meta/example_meta.py @@ -78,12 +78,12 @@ class BenchMeta(bch.ParametrizedSweep): """This class uses bencher to display the multidimensional types bencher can represent""" float_vars = bch.IntSweep( - default=1, bounds=(0, 3), doc="The number of floating point variables that are swept" + default=1, bounds=(0, 4), doc="The number of floating point variables that are swept" ) categorical_vars = bch.IntSweep( default=1, bounds=(0, 3), doc="The number of categorical variables that are swept" ) - sample_with_repeats = bch.IntSweep(default=1, bounds=(1, 2)) + sample_with_repeats = bch.IntSweep(default=1, bounds=(1, 10)) sample_over_time = bch.BoolSweep(default=False) @@ -143,16 +143,16 @@ def __call__(self, **kwargs: Any) -> Any: def example_meta( run_cfg: bch.BenchRunCfg = bch.BenchRunCfg(), report: bch.BenchReport = bch.BenchReport() ) -> bch.Bench: - bench = bch.Bench("bench_meta", BenchMeta(), report=report, run_cfg=run_cfg) + bench = BenchMeta().to_bench(run_cfg, report) bench.plot_sweep( title="Meta Bench", description="""## All Combinations of Variable Sweeps and Resulting Plots This uses bencher to display all the combinatios of plots bencher is able to produce""", input_vars=[ - BenchMeta.param.float_vars, + BenchMeta.param.float_vars.with_sample_values([0, 1, 2, 3]), BenchMeta.param.categorical_vars, - BenchMeta.param.sample_with_repeats, + BenchMeta.param.sample_with_repeats.with_sample_values([1, 2]), # BenchMeta.param.sample_over_time, ], const_vars=[ diff --git a/bencher/example/meta/example_meta_cat.py b/bencher/example/meta/example_meta_cat.py new file mode 100644 index 00000000..7314c0df --- /dev/null +++ b/bencher/example/meta/example_meta_cat.py @@ -0,0 +1,25 @@ +import bencher as bch +from bencher.example.meta.example_meta import BenchMeta + + +def example_meta_cat( + run_cfg: bch.BenchRunCfg = bch.BenchRunCfg(), report: bch.BenchReport = bch.BenchReport() +) -> bch.Bench: + bench = BenchMeta().to_bench(run_cfg, report) + + bench.plot_sweep( + title="Sweeping Categorical Variables", + input_vars=[ + BenchMeta.param.categorical_vars.with_sample_values([1, 2, 3]), + BenchMeta.param.sample_with_repeats.with_sample_values([1, 2]), + ], + const_vars=[ + BenchMeta.param.float_vars.with_const(0), + ], + ) + + return bench + + +if __name__ == "__main__": + example_meta_cat().report.show() diff --git a/bencher/example/meta/example_meta_float.py b/bencher/example/meta/example_meta_float.py new file mode 100644 index 00000000..41184a24 --- /dev/null +++ b/bencher/example/meta/example_meta_float.py @@ -0,0 +1,23 @@ +import bencher as bch +from bencher.example.meta.example_meta import BenchMeta + + +def example_meta_float( + run_cfg: bch.BenchRunCfg = bch.BenchRunCfg(), report: bch.BenchReport = bch.BenchReport() +) -> bch.Bench: + bench = BenchMeta().to_bench(run_cfg, report) + + bench.plot_sweep( + title="Sweeping Floating Point Variables", + input_vars=[BenchMeta.param.float_vars.with_sample_values([1, 2, 3, 4])], + const_vars=[ + BenchMeta.param.categorical_vars.with_const(0), + BenchMeta.param.level.with_const(3), + ], + ) + + return bench + + +if __name__ == "__main__": + example_meta_float().report.show() diff --git a/bencher/example/example_meta_levels.py b/bencher/example/meta/example_meta_levels.py similarity index 90% rename from bencher/example/example_meta_levels.py rename to bencher/example/meta/example_meta_levels.py index 0ff00eb6..513095ec 100644 --- a/bencher/example/example_meta_levels.py +++ b/bencher/example/meta/example_meta_levels.py @@ -1,11 +1,11 @@ import bencher as bch -from bencher.example.example_meta import BenchMeta +from bencher.example.meta.example_meta import BenchMeta def example_meta_levels( run_cfg: bch.BenchRunCfg = bch.BenchRunCfg(), report: bch.BenchReport = bch.BenchReport() ) -> bch.Bench: - bench = bch.Bench("bench_meta", BenchMeta(), report=report, run_cfg=run_cfg) + bench = BenchMeta().to_bench(run_cfg, report) bench.plot_sweep( title="Using Levels to define sample density", diff --git a/bencher/results/bench_result_base.py b/bencher/results/bench_result_base.py index 43e98047..1329069b 100644 --- a/bencher/results/bench_result_base.py +++ b/bencher/results/bench_result_base.py @@ -57,6 +57,10 @@ def to_hv_dataset( Returns: hv.Dataset: results in the form of a holoviews dataset """ + + if reduce == ReduceType.NONE: + kdims = [i.name for i in self.bench_cfg.all_vars] + return hv.Dataset(self.to_dataset(reduce, result_var), kdims=kdims) return hv.Dataset(self.to_dataset(reduce, result_var)) def to_dataset( diff --git a/bencher/variables/parametrised_sweep.py b/bencher/variables/parametrised_sweep.py index 373b083e..3e97d063 100644 --- a/bencher/variables/parametrised_sweep.py +++ b/bencher/variables/parametrised_sweep.py @@ -16,6 +16,7 @@ ResultContainer, ResultReference, ) + from uuid import uuid4 @@ -207,7 +208,12 @@ def gen_video_path(self, video_name: str) -> str: def gen_image_path(self, image_name: str, filetype=".png") -> str: return self.gen_path(image_name, "img", filetype) - def to_bench(self, run_cfg=None, report=None): + def to_bench(self, run_cfg=None, report=None, name: str = None): from bencher import Bench - return Bench(self.name, self, run_cfg=run_cfg, report=report) + assert isinstance(self, ParametrizedSweep) + + if name is None: + name = self.name + + return Bench(name, self, run_cfg=run_cfg, report=report) diff --git a/index.html b/index.html index 4745395e..fcae2378 100644 --- a/index.html +++ b/index.html @@ -25,10 +25,11 @@ Bokeh.set_log_level("info"); -
+
+
-