holobench 1.2.0__py3-none-any.whl → 1.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,7 @@ def example_1D_float(
26
26
  result_vars=[ExampleBenchCfgOut.param.out_sin],
27
27
  description=example_1D_float.__doc__,
28
28
  )
29
+
29
30
  return bench
30
31
 
31
32
 
@@ -78,12 +78,12 @@ class BenchMeta(bch.ParametrizedSweep):
78
78
  """This class uses bencher to display the multidimensional types bencher can represent"""
79
79
 
80
80
  float_vars = bch.IntSweep(
81
- default=1, bounds=(0, 3), doc="The number of floating point variables that are swept"
81
+ default=1, bounds=(0, 4), doc="The number of floating point variables that are swept"
82
82
  )
83
83
  categorical_vars = bch.IntSweep(
84
84
  default=1, bounds=(0, 3), doc="The number of categorical variables that are swept"
85
85
  )
86
- sample_with_repeats = bch.IntSweep(default=1, bounds=(1, 2))
86
+ sample_with_repeats = bch.IntSweep(default=1, bounds=(1, 10))
87
87
 
88
88
  sample_over_time = bch.BoolSweep(default=False)
89
89
 
@@ -143,16 +143,16 @@ class BenchMeta(bch.ParametrizedSweep):
143
143
  def example_meta(
144
144
  run_cfg: bch.BenchRunCfg = bch.BenchRunCfg(), report: bch.BenchReport = bch.BenchReport()
145
145
  ) -> bch.Bench:
146
- bench = bch.Bench("bench_meta", BenchMeta(), report=report, run_cfg=run_cfg)
146
+ bench = BenchMeta().to_bench(run_cfg, report)
147
147
 
148
148
  bench.plot_sweep(
149
149
  title="Meta Bench",
150
150
  description="""## All Combinations of Variable Sweeps and Resulting Plots
151
151
  This uses bencher to display all the combinatios of plots bencher is able to produce""",
152
152
  input_vars=[
153
- BenchMeta.param.float_vars,
153
+ BenchMeta.param.float_vars.with_sample_values([0, 1, 2, 3]),
154
154
  BenchMeta.param.categorical_vars,
155
- BenchMeta.param.sample_with_repeats,
155
+ BenchMeta.param.sample_with_repeats.with_sample_values([1, 2]),
156
156
  # BenchMeta.param.sample_over_time,
157
157
  ],
158
158
  const_vars=[
@@ -0,0 +1,25 @@
1
+ import bencher as bch
2
+ from bencher.example.meta.example_meta import BenchMeta
3
+
4
+
5
+ def example_meta_cat(
6
+ run_cfg: bch.BenchRunCfg = bch.BenchRunCfg(), report: bch.BenchReport = bch.BenchReport()
7
+ ) -> bch.Bench:
8
+ bench = BenchMeta().to_bench(run_cfg, report)
9
+
10
+ bench.plot_sweep(
11
+ title="Sweeping Categorical Variables",
12
+ input_vars=[
13
+ BenchMeta.param.categorical_vars.with_sample_values([1, 2, 3]),
14
+ BenchMeta.param.sample_with_repeats.with_sample_values([1, 2]),
15
+ ],
16
+ const_vars=[
17
+ BenchMeta.param.float_vars.with_const(0),
18
+ ],
19
+ )
20
+
21
+ return bench
22
+
23
+
24
+ if __name__ == "__main__":
25
+ example_meta_cat().report.show()
@@ -0,0 +1,23 @@
1
+ import bencher as bch
2
+ from bencher.example.meta.example_meta import BenchMeta
3
+
4
+
5
+ def example_meta_float(
6
+ run_cfg: bch.BenchRunCfg = bch.BenchRunCfg(), report: bch.BenchReport = bch.BenchReport()
7
+ ) -> bch.Bench:
8
+ bench = BenchMeta().to_bench(run_cfg, report)
9
+
10
+ bench.plot_sweep(
11
+ title="Sweeping Floating Point Variables",
12
+ input_vars=[BenchMeta.param.float_vars.with_sample_values([1, 2, 3, 4])],
13
+ const_vars=[
14
+ BenchMeta.param.categorical_vars.with_const(0),
15
+ BenchMeta.param.level.with_const(3),
16
+ ],
17
+ )
18
+
19
+ return bench
20
+
21
+
22
+ if __name__ == "__main__":
23
+ example_meta_float().report.show()
@@ -1,11 +1,11 @@
1
1
  import bencher as bch
2
- from bencher.example.example_meta import BenchMeta
2
+ from bencher.example.meta.example_meta import BenchMeta
3
3
 
4
4
 
5
5
  def example_meta_levels(
6
6
  run_cfg: bch.BenchRunCfg = bch.BenchRunCfg(), report: bch.BenchReport = bch.BenchReport()
7
7
  ) -> bch.Bench:
8
- bench = bch.Bench("bench_meta", BenchMeta(), report=report, run_cfg=run_cfg)
8
+ bench = BenchMeta().to_bench(run_cfg, report)
9
9
 
10
10
  bench.plot_sweep(
11
11
  title="Using Levels to define sample density",
@@ -4,7 +4,6 @@ from enum import Enum, auto
4
4
  import xarray as xr
5
5
  from param import Parameter
6
6
  import holoviews as hv
7
- import numpy as np
8
7
  from functools import partial
9
8
  from bencher.utils import int_to_col, color_tuple_to_css
10
9
 
@@ -59,37 +58,39 @@ class BenchResultBase(OptunaResult):
59
58
  hv.Dataset: results in the form of a holoviews dataset
60
59
  """
61
60
 
61
+ if reduce == ReduceType.NONE:
62
+ kdims = [i.name for i in self.bench_cfg.all_vars]
63
+ return hv.Dataset(self.to_dataset(reduce, result_var), kdims=kdims)
64
+ return hv.Dataset(self.to_dataset(reduce, result_var))
65
+
66
+ def to_dataset(
67
+ self, reduce: ReduceType = ReduceType.AUTO, result_var: ResultVar = None
68
+ ) -> xr.Dataset:
69
+ """Generate a summarised xarray dataset.
70
+
71
+ Args:
72
+ reduce (ReduceType, optional): Optionally perform reduce options on the dataset. By default the returned dataset will calculate the mean and standard devation 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.
73
+
74
+ Returns:
75
+ xr.Dataset: results in the form of an xarray dataset
76
+ """
62
77
  if reduce == ReduceType.AUTO:
63
78
  reduce = ReduceType.REDUCE if self.bench_cfg.repeats > 1 else ReduceType.SQUEEZE
64
79
 
65
- vdims = [r.name for r in self.bench_cfg.result_vars]
66
- kdims = [i.name for i in self.bench_cfg.all_vars]
67
-
68
80
  ds = self.ds if result_var is None else self.ds[result_var.name]
81
+
69
82
  match (reduce):
70
83
  case ReduceType.REDUCE:
71
- # if result_var
72
- vdims = []
73
- non_sum = []
74
- for r in self.bench_cfg.result_vars:
75
- if isinstance(r, ResultVar):
76
- vdims.append(r.name)
77
- else:
78
- non_sum.append(r.name)
79
-
80
- ds_num = ds.drop_vars(non_sum)
81
- return hv.Dataset(ds_num, kdims=kdims, vdims=vdims).reduce(
82
- ["repeat"], np.mean, np.std
83
- )
84
+ ds_reduce_mean = ds.mean(dim="repeat", keep_attrs=True)
85
+ ds_reduce_std = ds.std(dim="repeat", keep_attrs=True)
86
+
87
+ for v in ds_reduce_mean.data_vars:
88
+ ds_reduce_mean[f"{v}_std"] = ds_reduce_std[v]
89
+ return ds_reduce_mean
84
90
  case ReduceType.SQUEEZE:
85
- return hv.Dataset(ds.squeeze(drop=True), vdims=vdims)
91
+ return ds.squeeze(drop=True)
86
92
  case _:
87
- return hv.Dataset(ds, kdims=kdims, vdims=vdims)
88
-
89
- def to_dataset(
90
- self, reduce: ReduceType = ReduceType.AUTO, result_var: ResultVar = None
91
- ) -> xr.Dataset:
92
- return self.to_hv_dataset(reduce=reduce, result_var=result_var).data
93
+ return ds
93
94
 
94
95
  def get_optimal_vec(
95
96
  self,
@@ -16,6 +16,7 @@ from bencher.variables.results import (
16
16
  ResultContainer,
17
17
  ResultReference,
18
18
  )
19
+
19
20
  from uuid import uuid4
20
21
 
21
22
 
@@ -206,3 +207,13 @@ class ParametrizedSweep(Parameterized):
206
207
 
207
208
  def gen_image_path(self, image_name: str, filetype=".png") -> str:
208
209
  return self.gen_path(image_name, "img", filetype)
210
+
211
+ def to_bench(self, run_cfg=None, report=None, name: str = None):
212
+ from bencher import Bench
213
+
214
+ assert isinstance(self, ParametrizedSweep)
215
+
216
+ if name is None:
217
+ name = self.name
218
+
219
+ return Bench(name, self, run_cfg=run_cfg, report=report)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: holobench
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: A package for benchmarking the performance of arbitrary functions
5
5
  Author-email: Austin Gregg-Smith <blooop@gmail.com>
6
6
  Requires-Python: >=3.10
@@ -8,14 +8,14 @@ Description-Content-Type: text/markdown
8
8
  Requires-Dist: holoviews>=1.15,<=1.18.1
9
9
  Requires-Dist: numpy>=1.0,<=1.26.2
10
10
  Requires-Dist: param>=1.13.0,<=2.0.1
11
- Requires-Dist: hvplot>=0.8,<=0.9.0
11
+ Requires-Dist: hvplot>=0.8,<=0.9.1
12
12
  Requires-Dist: panel>=1.2.3,<1.4
13
13
  Requires-Dist: diskcache>=5.6,<=5.6.3
14
- Requires-Dist: optuna>=3.2,<=3.4.0
15
- Requires-Dist: xarray>=2023.7,<=2023.11.0
14
+ Requires-Dist: optuna>=3.2,<=3.5.0
15
+ Requires-Dist: xarray>=2023.7,<=2023.12.0
16
16
  Requires-Dist: plotly>=5.15,<=5.18.0
17
17
  Requires-Dist: sortedcontainers>=2.4,<=2.4
18
- Requires-Dist: pandas>=2.0,<=2.1.3
18
+ Requires-Dist: pandas>=2.0,<=2.1.4
19
19
  Requires-Dist: strenum>=0.4.0,<=0.4.15
20
20
  Requires-Dist: seaborn>=0.12.1,<=0.13.0
21
21
  Requires-Dist: scikit-learn>=1.2,<=1.3.2
@@ -23,13 +23,13 @@ Requires-Dist: str2bool>=1.1,<=1.1
23
23
  Requires-Dist: mortgage>=1.0.5,<=1.0.5
24
24
  Requires-Dist: scoop>=0.7.0,<=0.7.2.0
25
25
  Requires-Dist: ffmpeg-downloader>=0.3.0,<=0.3.0
26
- Requires-Dist: black>=23,<=23.11.0 ; extra == "test"
27
- Requires-Dist: pylint>=2.16,<=3.0.2 ; extra == "test"
26
+ Requires-Dist: black>=23,<=23.12.1 ; extra == "test"
27
+ Requires-Dist: pylint>=2.16,<=3.0.3 ; extra == "test"
28
28
  Requires-Dist: pytest-cov>=4.1,<=4.1 ; extra == "test"
29
29
  Requires-Dist: pytest>=7.4,<=7.4.3 ; extra == "test"
30
- Requires-Dist: hypothesis>=6.82,<=6.91.0 ; extra == "test"
31
- Requires-Dist: ruff>=0.0.280,<=0.1.6 ; extra == "test"
32
- Requires-Dist: coverage>=7.2.7,<=7.3.2 ; extra == "test"
30
+ Requires-Dist: hypothesis>=6.82,<=6.92.2 ; extra == "test"
31
+ Requires-Dist: ruff>=0.0.280,<=0.1.9 ; extra == "test"
32
+ Requires-Dist: coverage>=7.2.7,<=7.4.0 ; extra == "test"
33
33
  Project-URL: Home, https://github.com/dyson-ai/bencher
34
34
  Project-URL: Source, https://github.com/dyson-ai/bencher
35
35
  Provides-Extra: test
@@ -23,15 +23,13 @@ bencher/example/example_holosweep_objects.py,sha256=vHuAtkM1VrJelHOazn_SJfzxNywK
23
23
  bencher/example/example_holosweep_tap.py,sha256=3ayQ0bTj_XWP_92ifQJAhe1whwPAj_xWHPkzC7fvqAY,4540
24
24
  bencher/example/example_image.py,sha256=xB1Y3J1kkOaJV--SXAEU3pfhZtXUo1oSIcfT1N9L-OE,2734
25
25
  bencher/example/example_levels.py,sha256=rpSNB571yfMnT7iO66Ds-DPGHWzOTM9FLMNfSetJdHY,6896
26
- bencher/example/example_meta.py,sha256=MAoaOMueLEi7QLY5iQwRjeIJvGhSBo2pOTYCgKh8zUc,5704
27
- bencher/example/example_meta_levels.py,sha256=6qR36qVJ6WBXLm9OJU01BGiT-Se9zi2OPlSh_xS-SdI,1449
28
26
  bencher/example/example_pareto.py,sha256=yyAg8Vb-5sgsS6LkYKT7T5Evcfg69FlCqCakUippSmU,2687
29
27
  bencher/example/example_sample_cache.py,sha256=7gf1BJ63VAgdqNuNXkbL9-jeTeC3kXA_PY9yG3ulTz0,4200
30
28
  bencher/example/example_sample_cache_context.py,sha256=IAUBbL78QM20R8evaq7L8I-xPxFDFykF1Gk1y2Ru1W0,4063
31
29
  bencher/example/example_simple.py,sha256=Nn2ixNx29jbgvwH2K5vDGhSFcqKLMNaP1occPxhHoU0,11703
32
30
  bencher/example/example_simple_bool.py,sha256=36KMSHyXZhzS1cp2TZnDLn7-GpShLdQ7mycuT0M3le8,1247
33
31
  bencher/example/example_simple_cat.py,sha256=YFccE84g37U2M3ByWYIcGNLXWdW_ktJbbZvGL0D6oHA,1759
34
- bencher/example/example_simple_float.py,sha256=ZI0L66Ff6DD2QPLGxpqDrOBfdD_f2W5Dft_FfqTWFpI,1322
32
+ bencher/example/example_simple_float.py,sha256=X4vsH0F4fZAoO0EKB1xIzFMY0f0Wyk8LV2plPlSEsbI,1323
35
33
  bencher/example/example_strings.py,sha256=BdsEZgLT9mOxLkBKNHz2XpPwwe4SzNTdjnY1WVlOmNM,1570
36
34
  bencher/example/example_time_event.py,sha256=y1vpK7UDrObEu0Z1x3e4OQzvGCQ7pF5GZvpKLegMbYk,2158
37
35
  bencher/example/example_video.py,sha256=ZvmaJUnIw-0v8nInbUrpv6qtp1HXEGLHrGiffPwzGWU,3389
@@ -45,6 +43,10 @@ bencher/example/experimental/example_streams.py,sha256=rrTmcmxDlirGoyTbJ4LT4fBIA
45
43
  bencher/example/experimental/example_template.py,sha256=XdIVS9RtLdE5GNnerWiZMXvP7n17lzuc_YTLqJTwb6Q,1172
46
44
  bencher/example/experimental/example_updates.py,sha256=rF4UgWY-CW6ohNtOpQklTuwbwVRvEM5j6edZOiMkspQ,1835
47
45
  bencher/example/experimental/example_vector.py,sha256=3o_1dA4dc2HL6uIEvDAcvLPVJB8jgkq1QZ3BQIL-LEo,3118
46
+ bencher/example/meta/example_meta.py,sha256=OpresXooPvkSVI3mfExqiATyGvd3o5x-dmIjhTH5Zf4,5734
47
+ bencher/example/meta/example_meta_cat.py,sha256=YKVUiZ7M1tFFYgUTVQZeOe-1bnmxOjLdWy3nmCoyEe0,693
48
+ bencher/example/meta/example_meta_float.py,sha256=GjfO1HfbCb0zscZ83U3PpD8QNffnsx1ZVC5I3hrJJd8,653
49
+ bencher/example/meta/example_meta_levels.py,sha256=HNkb7Qej3rlf3blp2XoV-Od4c6sgRoM9aIQnBI5hv9I,1423
48
50
  bencher/example/mortgage/example_investment.py,sha256=agWmuFAt3fDimGAcgJBNIQO0OBA1w0ssotuyvWaKREQ,2025
49
51
  bencher/example/mortgage/example_mortgage.py,sha256=I4LD7BD8sxCYoDsgG5BynN3rRiyDAZqGcZySz94qYD0,2355
50
52
  bencher/example/mortgage/example_mortgage_simulator.py,sha256=OXFYYBYqgXdO_IHsf_cELqWqi_CCGfKnaZ9gUrF5cgA,8663
@@ -58,16 +60,16 @@ bencher/plotting/plot_filter.py,sha256=Zff02hEcRffiqDEoXUHVZQJK5kW4HbMxe2GYCrxI8
58
60
  bencher/plotting/plt_cnt_cfg.py,sha256=BkiAsgHm35Mqb5OsjULGVK0Q6pGZ0WSsJxxwSOrbaQs,3124
59
61
  bencher/results/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
62
  bencher/results/bench_result.py,sha256=O0RxxUoudT43zukIKEmwaj8Q156UrEfwyj8NGFFwI0c,2797
61
- bencher/results/bench_result_base.py,sha256=8_cLabvqWh0cm5xLyFMwE71FOxRbWTMOEpfUbm13dJc,12997
63
+ bencher/results/bench_result_base.py,sha256=2Ds1KKCv17vMJ7cJwwmmWPPsUde2augP466jxtUuvZs,13378
62
64
  bencher/results/holoview_result.py,sha256=h-Q48m2dkHLPmvHnxmREpzt7MzQ-6iYLWrURDdLPjOw,21310
63
65
  bencher/results/optuna_result.py,sha256=704l1eFJUQGTmnTaj2pIJ9ocRehLgu4PwMYmJU2rY9w,12399
64
66
  bencher/results/panel_result.py,sha256=Fkp7eWt7lzmnM5R6MdEsBeyGg7CEJmlSEHWzNujcIUc,3479
65
67
  bencher/results/plotly_result.py,sha256=vny-HPyWIWzsLWQaOvMswtgVDub9bgQzqcartlFCqjI,2368
66
68
  bencher/variables/inputs.py,sha256=5yN45tet1cPyok6R_XD8xn1FZB5OUUp_TWWF2wIVVdg,6247
67
- bencher/variables/parametrised_sweep.py,sha256=fhKX4-LInKzZEb1VsGqkZ8XymNJTSGVx3e5ZoNCA5o8,7205
69
+ bencher/variables/parametrised_sweep.py,sha256=q633o5zFY7P0ZeHX4G3AW3jYBfwoqLZZoUeibcln1u0,7483
68
70
  bencher/variables/results.py,sha256=yXdLjfGPSerWhipw_GDZJpBB8KQgCqcdreb8WjIeah8,5119
69
71
  bencher/variables/sweep_base.py,sha256=I1LEeG1y5Jsw0a-Ik03t0tSzcfENht2GmBECJ3KNs28,6559
70
72
  bencher/variables/time.py,sha256=Le7s8_oUYJD4wCqwQw-a_FRDpYQOi8CqMbGYsBF07jg,2860
71
- holobench-1.2.0.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
72
- holobench-1.2.0.dist-info/METADATA,sha256=EsC9x6fwiTqxlQZ6vcx5yc_D5XscdISfsewUbaoksF4,4991
73
- holobench-1.2.0.dist-info/RECORD,,
73
+ holobench-1.2.2.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
74
+ holobench-1.2.2.dist-info/METADATA,sha256=WHKNMDGXx8amGQvMSfJ17lxr4jMPjXaxZjG55M348cU,4991
75
+ holobench-1.2.2.dist-info/RECORD,,