holobench 1.30.2__py3-none-any.whl → 1.30.3__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.
@@ -1,11 +1,9 @@
1
1
  # pylint: disable=duplicate-code
2
-
3
2
  import numpy as np
4
-
5
3
  import bencher as bch
6
4
 
7
5
 
8
- class VolumeSample(bch.ParametrizedSweep):
6
+ class VolumeSweep(bch.ParametrizedSweep):
9
7
  """A class to represent a 3D point in space."""
10
8
 
11
9
  x = bch.FloatSweep(
@@ -18,10 +16,6 @@ class VolumeSample(bch.ParametrizedSweep):
18
16
  default=0, bounds=[-1.0, 1.0], doc="z coordinate of the sample volume", samples=6
19
17
  )
20
18
 
21
-
22
- class VolumeResult(bch.ParametrizedSweep):
23
- """A class to represent the properties of a volume sample."""
24
-
25
19
  value = bch.ResultVar("ul", doc="The scalar value of the 3D volume field")
26
20
  occupancy = bch.ResultVar(
27
21
  "occupied", doc="If the value is > 0.5 this point is considered occupied"
@@ -32,33 +26,25 @@ class VolumeResult(bch.ParametrizedSweep):
32
26
  3, "vec", doc="The same vector field but only showing values in a sphere of radius 0.5"
33
27
  )
34
28
 
29
+ def __call__(self, **kwargs) -> dict:
30
+ """This function takes a 3D point as input and returns distance of that point to the origin."""
31
+ self.update_params_from_kwargs(**kwargs)
32
+ self.value = np.linalg.norm(np.array([self.x, self.y, self.z])) # distance to origin
33
+ self.occupancy = float(self.value < 0.5)
34
+ # from https://plotly.com/python/3d-volume-plots/
35
+ self.interesting = np.sin(np.pi * self.x) * np.cos(np.pi * self.z) * np.sin(np.pi * self.y)
36
+ self.interesting_vec = [
37
+ np.sin(np.pi * self.x),
38
+ np.cos(np.pi * self.z),
39
+ np.sin(np.pi * self.y),
40
+ ]
35
41
 
36
- def bench_fn(point: VolumeSample) -> VolumeResult:
37
- """This function takes a 3D point as input and returns distance of that point to the origin.
42
+ if self.occupancy:
43
+ self.interesting_vec_and_occ = self.interesting_vec
44
+ else:
45
+ self.interesting_vec_and_occ = [0, 0, 0]
38
46
 
39
- Args:
40
- point (VolumeSample): Sample point
41
-
42
- Returns:
43
- VolumeResult: Value at that point
44
- """
45
- output = VolumeResult()
46
- output.value = np.linalg.norm(np.array([point.x, point.y, point.z])) # distance to origin
47
- output.occupancy = float(output.value < 0.5)
48
- # from https://plotly.com/python/3d-volume-plots/
49
- output.interesting = np.sin(np.pi * point.x) * np.cos(np.pi * point.z) * np.sin(np.pi * point.y)
50
- output.interesting_vec = [
51
- np.sin(np.pi * point.x),
52
- np.cos(np.pi * point.z),
53
- np.sin(np.pi * point.y),
54
- ]
55
-
56
- if output.occupancy:
57
- output.interesting_vec_and_occ = output.interesting_vec
58
- else:
59
- output.interesting_vec_and_occ = [0, 0, 0]
60
-
61
- return output
47
+ return super().__call__()
62
48
 
63
49
 
64
50
  def example_floats3D(
@@ -72,21 +58,15 @@ def example_floats3D(
72
58
  Returns:
73
59
  Bench: results of the parameter sweep
74
60
  """
75
- bench = bch.Bench(
76
- "Bencher_Example_Floats",
77
- bench_fn,
78
- VolumeSample,
79
- run_cfg=run_cfg,
80
- report=report,
81
- )
61
+ bench = VolumeSweep().to_bench(run_cfg=run_cfg, report=report)
82
62
 
83
63
  bench.plot_sweep(
84
64
  title="Float 3D Example",
85
- input_vars=[VolumeSample.param.x, VolumeSample.param.y, VolumeSample.param.z],
65
+ input_vars=["x", "y", "z"],
86
66
  result_vars=[
87
- VolumeResult.param.value,
88
- VolumeResult.param.occupancy,
89
- VolumeResult.param.interesting,
67
+ "value",
68
+ "occupancy",
69
+ "interesting",
90
70
  ],
91
71
  description="""This example shows how to sample 3 floating point variables and plot a volumetric representation of the results. The benchmark function returns the distance to the origin""",
92
72
  post_description="Here you can see concentric shells as the value of the function increases with distance from the origin. The occupancy graph should show a sphere with radius=0.5",
@@ -97,5 +77,5 @@ def example_floats3D(
97
77
 
98
78
  if __name__ == "__main__":
99
79
  ex_run_cfg = bch.BenchRunCfg()
100
- ex_run_cfg.level = 3
80
+ ex_run_cfg.level = 6
101
81
  example_floats3D(ex_run_cfg).report.show()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: holobench
3
- Version: 1.30.2
3
+ Version: 1.30.3
4
4
  Summary: A package for benchmarking the performance of arbitrary functions
5
5
  Project-URL: Repository, https://github.com/dyson-ai/bencher
6
6
  Project-URL: Home, https://github.com/dyson-ai/bencher
@@ -13,12 +13,12 @@ Requires-Dist: holoviews<=1.19.1,>=1.15
13
13
  Requires-Dist: hvplot<=0.10.0,>=0.8
14
14
  Requires-Dist: matplotlib<=3.9.2,>=3.6.3
15
15
  Requires-Dist: moviepy-fix-codec
16
- Requires-Dist: numpy<=2.1.0,>=1.0
16
+ Requires-Dist: numpy<=2.1.3,>=1.0
17
17
  Requires-Dist: optuna<=4.0.0,>=3.2
18
18
  Requires-Dist: pandas<=2.2.2,>=2.0
19
19
  Requires-Dist: panel<=1.4.5,>=1.3.6
20
20
  Requires-Dist: param<=2.1.1,>=1.13.0
21
- Requires-Dist: plotly<=5.24.0,>=5.15
21
+ Requires-Dist: plotly<=5.24.1,>=5.15
22
22
  Requires-Dist: scikit-learn<=1.5.1,>=1.2
23
23
  Requires-Dist: scoop<=0.7.2.0,>=0.7.0
24
24
  Requires-Dist: sortedcontainers<=2.4,>=2.4
@@ -23,7 +23,7 @@ bencher/example/example_custom_sweep2.py,sha256=6RBiyVVaxAh5Aul85DfYA5P-lwhwW3Bb
23
23
  bencher/example/example_dataframe.py,sha256=aGSdMnsRvRC2dgkUVmzEJz5yo6k1lPjsUM6gFShNcRI,1792
24
24
  bencher/example/example_docs.py,sha256=aUi33O543JBPoOGlpHaY2eA74GR7cHH_6-hcC8xf3z0,1174
25
25
  bencher/example/example_filepath.py,sha256=O3VO9rWAXB_1tagVSvxhiSMjcTkgZe2duw7W17ij7po,827
26
- bencher/example/example_float3D.py,sha256=pwi3YlDad3NL4IrfMK2V5yV1CRpqfmUO-zUnGmVYxDs,3425
26
+ bencher/example/example_float3D.py,sha256=Ya9zIfUZmbqV6GZrRjcV44uMnKeKgG6RrLBsky0P5LY,3066
27
27
  bencher/example/example_float_cat.py,sha256=nQDBWYRVZrJW5ABIizqcD6mXswHWSdEDzM-FeYFqYqY,3821
28
28
  bencher/example/example_floats.py,sha256=HcQgfwldTVeFBmBTMtZ0yRy17ZJ4cfJeI_t8TxY2iOI,4269
29
29
  bencher/example/example_floats2D.py,sha256=D0kljoUCinMKCEW-Zg-cQ8sYu_yPCZqzKJ9tRtt-Ono,3697
@@ -89,7 +89,7 @@ bencher/variables/results.py,sha256=Wq14e8rAj5mcK22325wcaeTMjgZ6JuduqceAHItHFY8,
89
89
  bencher/variables/sweep_base.py,sha256=gfEhKvsb16ZLbe38JewZqu0AMOHpsqwRbZbt-aCg9Bc,6258
90
90
  bencher/variables/time.py,sha256=zcRS5p4ZkFjMta9nZMEuWv86rLnPkUSqyO69QwI5q3E,3142
91
91
  resource/bencher,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
92
- holobench-1.30.2.dist-info/METADATA,sha256=xFu1ubVzZcmc0ydMa4H6bWHxVZ_GAmM_dAkUGSABbwg,6360
93
- holobench-1.30.2.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
94
- holobench-1.30.2.dist-info/licenses/LICENSE,sha256=dSHXTdRY4Y7qGFMv63UksV700iff7iE-p7GGs6Sbnvo,1065
95
- holobench-1.30.2.dist-info/RECORD,,
92
+ holobench-1.30.3.dist-info/METADATA,sha256=Hcm68cVxVMskIezkmj2E74MsOo37QZYg-OB9V5kX3so,6360
93
+ holobench-1.30.3.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
94
+ holobench-1.30.3.dist-info/licenses/LICENSE,sha256=dSHXTdRY4Y7qGFMv63UksV700iff7iE-p7GGs6Sbnvo,1065
95
+ holobench-1.30.3.dist-info/RECORD,,