holobench 1.2.4__py3-none-any.whl → 1.3.1__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.
@@ -12,6 +12,7 @@ from bencher.variables.results import OptDir
12
12
  from copy import deepcopy
13
13
  from bencher.results.optuna_result import OptunaResult
14
14
  from bencher.variables.results import ResultVar
15
+ from bencher.results.float_formatter import FormatFloat
15
16
  import panel as pn
16
17
 
17
18
 
@@ -293,12 +294,19 @@ class BenchResultBase(OptunaResult):
293
294
 
294
295
  container_args = {"name": name, "styles": {"background": background_col}}
295
296
  outer_container = (
296
- pn.Row(**container_args) if horizontal else pn.Column(**container_args, align="end")
297
+ pn.Row(**container_args) if horizontal else pn.Column(**container_args)
297
298
  )
298
299
 
300
+ max_len = 0
301
+
299
302
  for i in range(dataset.sizes[dim_sel]):
300
303
  sliced = dataset.isel({dim_sel: i})
301
- label = f"{dim_sel}={sliced.coords[dim_sel].values}"
304
+
305
+ lable_val = sliced.coords[dim_sel].values.item()
306
+ if isinstance(lable_val, (int, float)):
307
+ lable_val = FormatFloat()(lable_val)
308
+
309
+ label = f"{dim_sel}={lable_val}"
302
310
 
303
311
  panes = self._to_panes_da(
304
312
  sliced,
@@ -321,12 +329,17 @@ class BenchResultBase(OptunaResult):
321
329
  inner_container = pn.Row(**container_args)
322
330
  align = ("end", "center")
323
331
 
324
- side = pn.pane.Markdown(f"{label}", align=align)
332
+ label_len = len(label)
333
+ if label_len > max_len:
334
+ max_len = label_len
335
+ side = pn.pane.Markdown(label, align=align)
325
336
 
326
337
  inner_container.append(side)
327
338
  inner_container.append(panes)
328
339
  outer_container.append(inner_container)
329
340
  # outer_container.append(pn.Row(inner_container, align="center"))
341
+ for c in outer_container:
342
+ c[0].width = max_len * 7
330
343
  else:
331
344
  return plot_callback(dataset=dataset, result_var=result_var, **kwargs)
332
345
 
@@ -0,0 +1,44 @@
1
+ # from https://stackoverflow.com/questions/22989372/how-to-format-a-floating-number-to-maximum-fixed-width-in-python
2
+
3
+
4
+ class FormatFloat:
5
+ def __init__(self, width=8):
6
+ self.width = width
7
+ self.maxnum = int("9" * (width - 1)) # 9999999
8
+ self.minnum = -int("9" * (width - 2)) # -999999
9
+
10
+ def __call__(self, x):
11
+ # for small numbers
12
+ # if -999,999 < given < 9,999,999:
13
+ if self.minnum < x < self.maxnum:
14
+ # o = f'{x:7}'
15
+ o = f"{x:{self.width - 1}}"
16
+
17
+ # converting int to float without adding zero
18
+ if "." not in o:
19
+ o += "."
20
+
21
+ # float longer than 8 will need rounding to fit width
22
+ elif len(o) > self.width:
23
+ # output = str(round(x, 7 - str(x).index(".")))
24
+ o = str(round(x, self.width - 1 - str(x).index(".")))
25
+ if len(o) < self.width:
26
+ o += (self.width - len(o)) * "0"
27
+
28
+ else:
29
+ # for exponents
30
+ # added a loop for super large numbers or negative as "-" is another char
31
+ # Added max(max_char, 5) to account for max length of less
32
+ # than 5, was having too much fun
33
+ # TODO can i come up with a threshold value for these up front,
34
+ # so that i dont have to do this calc for every value??
35
+ for n in range(max(self.width, 5) - 5, 0, -1):
36
+ fill = f".{n}e"
37
+ o = f"{x:{fill}}".replace("+0", "+")
38
+
39
+ # if all good stop looping
40
+ if len(o) == self.width:
41
+ break
42
+ else:
43
+ raise ValueError(f"Number is too large to fit in {self.width} characters", x)
44
+ return o
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: holobench
3
- Version: 1.2.4
3
+ Version: 1.3.1
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
@@ -9,7 +9,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
11
  Requires-Dist: hvplot>=0.8,<=0.9.1
12
- Requires-Dist: panel>=1.2.3,<1.4
12
+ Requires-Dist: matplotlib>=3.6.3,<=3.8.2
13
+ Requires-Dist: panel>=1.3.6,<=1.3.6
13
14
  Requires-Dist: diskcache>=5.6,<=5.6.3
14
15
  Requires-Dist: optuna>=3.2,<=3.5.0
15
16
  Requires-Dist: xarray>=2023.7,<=2023.12.0
@@ -17,7 +18,6 @@ Requires-Dist: plotly>=5.15,<=5.18.0
17
18
  Requires-Dist: sortedcontainers>=2.4,<=2.4
18
19
  Requires-Dist: pandas>=2.0,<=2.1.4
19
20
  Requires-Dist: strenum>=0.4.0,<=0.4.15
20
- Requires-Dist: seaborn>=0.12.1,<=0.13.0
21
21
  Requires-Dist: scikit-learn>=1.2,<=1.3.2
22
22
  Requires-Dist: str2bool>=1.1,<=1.1
23
23
  Requires-Dist: scoop>=0.7.0,<=0.7.2.0
@@ -25,7 +25,7 @@ Requires-Dist: ffmpeg-downloader>=0.3.0,<=0.3.0
25
25
  Requires-Dist: black>=23,<=23.12.1 ; extra == "test"
26
26
  Requires-Dist: pylint>=2.16,<=3.0.3 ; extra == "test"
27
27
  Requires-Dist: pytest-cov>=4.1,<=4.1 ; extra == "test"
28
- Requires-Dist: pytest>=7.4,<=7.4.3 ; extra == "test"
28
+ Requires-Dist: pytest>=7.4,<=7.4.4 ; extra == "test"
29
29
  Requires-Dist: hypothesis>=6.82,<=6.92.2 ; extra == "test"
30
30
  Requires-Dist: ruff>=0.0.280,<=0.1.9 ; extra == "test"
31
31
  Requires-Dist: coverage>=7.2.7,<=7.4.0 ; extra == "test"
@@ -57,7 +57,8 @@ bencher/plotting/plot_filter.py,sha256=Zff02hEcRffiqDEoXUHVZQJK5kW4HbMxe2GYCrxI8
57
57
  bencher/plotting/plt_cnt_cfg.py,sha256=BkiAsgHm35Mqb5OsjULGVK0Q6pGZ0WSsJxxwSOrbaQs,3124
58
58
  bencher/results/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
59
  bencher/results/bench_result.py,sha256=O0RxxUoudT43zukIKEmwaj8Q156UrEfwyj8NGFFwI0c,2797
60
- bencher/results/bench_result_base.py,sha256=SGln2bdnUUCrW3e4mdUHLyqejaako-A48Yfc1s0S1BA,13539
60
+ bencher/results/bench_result_base.py,sha256=_TQk3WRORY6obm57ZhsDwk6Gbq-d8u_q69OgGKtS2sU,13960
61
+ bencher/results/float_formatter.py,sha256=sX6HNCyaXdHDxC8ybVUHwCJ3qOKbPUkBOplVIHtKWjM,1746
61
62
  bencher/results/holoview_result.py,sha256=h-Q48m2dkHLPmvHnxmREpzt7MzQ-6iYLWrURDdLPjOw,21310
62
63
  bencher/results/optuna_result.py,sha256=704l1eFJUQGTmnTaj2pIJ9ocRehLgu4PwMYmJU2rY9w,12399
63
64
  bencher/results/panel_result.py,sha256=Fkp7eWt7lzmnM5R6MdEsBeyGg7CEJmlSEHWzNujcIUc,3479
@@ -67,6 +68,6 @@ bencher/variables/parametrised_sweep.py,sha256=q633o5zFY7P0ZeHX4G3AW3jYBfwoqLZZo
67
68
  bencher/variables/results.py,sha256=yXdLjfGPSerWhipw_GDZJpBB8KQgCqcdreb8WjIeah8,5119
68
69
  bencher/variables/sweep_base.py,sha256=I1LEeG1y5Jsw0a-Ik03t0tSzcfENht2GmBECJ3KNs28,6559
69
70
  bencher/variables/time.py,sha256=Le7s8_oUYJD4wCqwQw-a_FRDpYQOi8CqMbGYsBF07jg,2860
70
- holobench-1.2.4.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
71
- holobench-1.2.4.dist-info/METADATA,sha256=wvb40_M92uqBLIgfNYWky5yqklmw69SnLDWtBtbJWFg,4952
72
- holobench-1.2.4.dist-info/RECORD,,
71
+ holobench-1.3.1.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
72
+ holobench-1.3.1.dist-info/METADATA,sha256=vSgr3cL-IZvlxj-D9jz245_78Lj85EPycjjP7ceaALI,4956
73
+ holobench-1.3.1.dist-info/RECORD,,