Skip to content

Commit

Permalink
Merge pull request #301 from dyson-ai/feature/less_ugly_lines
Browse files Browse the repository at this point in the history
Feature/less ugly lines
  • Loading branch information
blooop committed Dec 31, 2023
2 parents 8b8cfc7 + 931160a commit 6789518
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 36 deletions.
34 changes: 34 additions & 0 deletions bencher/example/example_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import bencher as bch
from bencher.example.example_video import example_video
from bencher.example.example_image import example_image
from bencher.example.meta.example_meta_levels import example_meta_levels
from bencher.example.meta.example_meta_cat import example_meta_cat
from bencher.example.meta.example_meta_float import example_meta_float


def example_docs(
run_cfg: bch.BenchRunCfg = bch.BenchRunCfg(), report: bch.BenchReport = bch.BenchReport()
) -> bch.Bench:
# b_run = bch.BenchRunner("bench_runner_test", run_cfg=run_cfg)
# b_run.add_run(example_categorical)
# b_run.add_run(example_floats)
# b_run.add_run(example_image)
# b_run.add_run(example_video)
# b_run.add_run(example_meta_levels)
# b_run.add_run(run_levels)
# b_run.run(level=4, grouped=True, save=True)
# b_run.shutdown()
run_cfg.repeats = 1
run_cfg.level = 2
example_image(run_cfg, report)
example_video(run_cfg, report)
example_meta_cat(report=report)
example_meta_float(report=report)
example_meta_levels(report=report)
# example_meta(run_cfg,report)

return report


if __name__ == "__main__":
example_docs().show()
1 change: 0 additions & 1 deletion bencher/example/example_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def points_to_polygon_png(self, points: list[float], filename: str):
ax.set_aspect("equal")
fig.add_axes(ax)
fig.savefig(filename, dpi=50)
plt.close()
return filename


Expand Down
2 changes: 1 addition & 1 deletion bencher/example/meta/example_meta_float.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def example_meta_float(

bench.plot_sweep(
title="Sweeping Floating Point Variables",
input_vars=[BenchMeta.param.float_vars.with_sample_values([1, 2, 3, 4])],
input_vars=[BenchMeta.param.float_vars.with_sample_values([1, 2, 3])],
const_vars=[
BenchMeta.param.categorical_vars.with_const(0),
BenchMeta.param.level.with_const(3),
Expand Down
5 changes: 4 additions & 1 deletion bencher/example/meta/example_meta_levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ def example_meta_levels(
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],
input_vars=[
BenchMeta.param.float_vars.with_sample_values([1, 2]),
BenchMeta.param.level.with_sample_values([2, 3, 4]),
],
const_vars=[
BenchMeta.param.categorical_vars.with_const(0),
],
Expand Down
8 changes: 6 additions & 2 deletions bencher/results/bench_result_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def _to_panes_da(

container_args = {"name": name, "styles": {"background": background_col}}
outer_container = (
pn.Row(**container_args) if horizontal else pn.Column(**container_args)
pn.Row(**container_args) if horizontal else pn.Column(**container_args, align="end")
)

for i in range(dataset.sizes[dim_sel]):
Expand All @@ -309,7 +309,10 @@ def _to_panes_da(
)
width = num_dims - target_dimension

container_args = {"name": name, "styles": {"border": f"{width}px solid grey"}}
container_args = {
"name": name,
"styles": {"border-bottom": f"{width}px solid grey"},
}

if horizontal:
inner_container = pn.Column(**container_args)
Expand All @@ -323,6 +326,7 @@ def _to_panes_da(
inner_container.append(side)
inner_container.append(panes)
outer_container.append(inner_container)
# outer_container.append(pn.Row(inner_container, align="center"))
else:
return plot_callback(dataset=dataset, result_var=result_var, **kwargs)

Expand Down
12 changes: 6 additions & 6 deletions index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "holobench"
version = "1.2.2"
version = "1.2.3"

authors = [{ name = "Austin Gregg-Smith", email = "blooop@gmail.com" }]
description = "A package for benchmarking the performance of arbitrary functions"
Expand Down
26 changes: 2 additions & 24 deletions test/test_bench_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
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.meta.example_meta_levels import example_meta_levels
from bencher.example.meta.example_meta import example_meta
from bencher.example.meta.example_meta_cat import example_meta_cat
from bencher.example.meta.example_meta_float import example_meta_float

from bencher.example.example_docs import example_docs

import os

Expand All @@ -49,30 +46,11 @@ def create_run_cfg(self) -> bch.BenchRunCfg:
def examples_asserts(self, example_result, save=False) -> None:
self.assertIsNotNone(example_result)
if save or self.generate_all:
# example_result.save("bencher/example/html")
path = example_result.report.save_index("cachedir")
self.assertTrue(os.path.exists(path))

def test_publish_docs(self):
run_cfg = self.create_run_cfg()
# b_run = bch.BenchRunner("bench_runner_test", run_cfg=run_cfg)
# b_run.add_run(example_categorical)
# b_run.add_run(example_floats)
# b_run.add_run(example_image)
# b_run.add_run(example_video)
# b_run.add_run(example_meta_levels)
# b_run.add_run(run_levels)
# b_run.run(level=4, grouped=True, save=True)
# b_run.shutdown()
report = bch.BenchReport()
example_image(run_cfg, report)
example_video(run_cfg, report)
example_meta_cat(run_cfg, report)
example_meta_float(run_cfg, report)
run_cfg.level = 4
example_meta_levels(run_cfg, report)
# example_meta(run_cfg,report)

report = example_docs(run_cfg=self.create_run_cfg())
report.save_index()

# def test_example_categorical(self) -> None:
Expand Down

0 comments on commit 6789518

Please sign in to comment.