Skip to content

Commit

Permalink
Merge pull request #291 from dyson-ai/feature/example_levels
Browse files Browse the repository at this point in the history
add example_meta_levels
  • Loading branch information
blooop authored Dec 23, 2023
2 parents bc8fb93 + 7a2720f commit 635590f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
13 changes: 0 additions & 13 deletions bencher/example/example_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
import holoviews as hv
import math

# class NegateConfig(StrEnum):

# none=auto()


class NoiseDistribution(StrEnum):
"""A categorical variable describing the types of random noise"""
Expand Down Expand Up @@ -167,15 +163,6 @@ def example_meta(
],
)

bench.plot_sweep(
title="Using Levels to define sample density",
description="Sample levels let you perform parameter sweeps without having to decide how many samples to take when defining the class. If you perform a sweep at level 2, then all the points are reused when sampling at level 3. The higher levels reuse the points from lower levels to avoid having to recompute potentially expensive samples. The other advantage is that it enables a workflow where you can quickly see the results of the sweep at a low resolution to sense check the code, and then run it at a high level to get the fidelity you want. When calling a sweep at a high level, you can publish the intermediate lower level results as the computiation continues so that you can track the progress of the computation and end the sweep early when you have sufficient resolution",
input_vars=[BenchMeta.param.float_vars.with_sample_values([1, 2]), BenchMeta.param.level],
const_vars=[
BenchMeta.param.categorical_vars.with_const(0),
],
)

return bench


Expand Down
23 changes: 23 additions & 0 deletions bencher/example/example_meta_levels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import bencher as bch
from bencher.example.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.plot_sweep(
title="Using Levels to define sample density",
description="Sample levels let you perform parameter sweeps without having to decide how many samples to take when defining the class. If you perform a sweep at level 2, then all the points are reused when sampling at level 3. The higher levels reuse the points from lower levels to avoid having to recompute potentially expensive samples. The other advantage is that it enables a workflow where you can quickly see the results of the sweep at a low resolution to sense check the code, and then run it at a high level to get the fidelity you want. When calling a sweep at a high level, you can publish the intermediate lower level results as the computiation continues so that you can track the progress of the computation and end the sweep early when you have sufficient resolution",
input_vars=[BenchMeta.param.float_vars.with_sample_values([1, 2]), BenchMeta.param.level],
const_vars=[
BenchMeta.param.categorical_vars.with_const(0),
],
)

return bench


if __name__ == "__main__":
example_meta_levels().report.show()
3 changes: 2 additions & 1 deletion test/test_bench_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from bencher.example.example_strings import example_strings
from bencher.example.example_image import example_image
from bencher.example.example_video import example_video
from bencher.example.example_meta_levels import example_meta_levels

import os

Expand Down Expand Up @@ -54,7 +55,7 @@ def test_publish_docs(self):
# b_run.add_run(example_floats)
b_run.add_run(example_image)
b_run.add_run(example_video)
# b_run.add_run(example_meta)
b_run.add_run(example_meta_levels)
# b_run.add_run(run_levels)

b_run.run(level=4, grouped=True, save=True)
Expand Down

0 comments on commit 635590f

Please sign in to comment.