holobench 1.40.1__py3-none-any.whl → 1.42.0__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.
- CHANGELOG.md +10 -0
- bencher/__init__.py +20 -2
- bencher/bench_cfg.py +265 -61
- bencher/bench_report.py +2 -2
- bencher/bench_runner.py +96 -10
- bencher/bencher.py +421 -89
- bencher/caching.py +1 -4
- bencher/class_enum.py +70 -7
- bencher/example/example_composable_container_image.py +60 -0
- bencher/example/example_composable_container_video.py +49 -0
- bencher/example/example_dataframe.py +2 -2
- bencher/example/example_image.py +17 -21
- bencher/example/example_image1.py +16 -20
- bencher/example/example_levels.py +17 -173
- bencher/example/example_pareto.py +107 -31
- bencher/example/example_rerun2.py +1 -1
- bencher/example/example_simple_bool.py +2 -2
- bencher/example/example_simple_float2d.py +6 -1
- bencher/example/example_video.py +35 -17
- bencher/example/experimental/example_hvplot_explorer.py +3 -4
- bencher/example/inputs_0D/example_0_in_1_out.py +25 -15
- bencher/example/inputs_0D/example_0_in_2_out.py +12 -3
- bencher/example/inputs_0_float/example_0_cat_in_2_out.py +88 -0
- bencher/example/inputs_0_float/example_1_cat_in_2_out.py +98 -0
- bencher/example/inputs_0_float/example_2_cat_in_2_out.py +107 -0
- bencher/example/inputs_0_float/example_3_cat_in_2_out.py +111 -0
- bencher/example/inputs_1D/example1d_common.py +48 -12
- bencher/example/inputs_1D/example_0_float_1_cat.py +33 -0
- bencher/example/inputs_1D/example_1_cat_in_2_out_repeats.py +68 -0
- bencher/example/inputs_1D/example_1_float_2_cat_repeats.py +15 -0
- bencher/example/inputs_1D/example_1_int_in_1_out.py +98 -0
- bencher/example/inputs_1D/example_1_int_in_2_out.py +101 -0
- bencher/example/inputs_1D/example_1_int_in_2_out_repeats.py +99 -0
- bencher/example/inputs_1_float/example_1_float_0_cat_in_2_out.py +117 -0
- bencher/example/inputs_1_float/example_1_float_1_cat_in_2_out.py +124 -0
- bencher/example/inputs_1_float/example_1_float_2_cat_in_2_out.py +132 -0
- bencher/example/inputs_1_float/example_1_float_3_cat_in_2_out.py +140 -0
- bencher/example/inputs_2D/example_2_cat_in_4_out_repeats.py +104 -0
- bencher/example/inputs_2_float/example_2_float_0_cat_in_2_out.py +98 -0
- bencher/example/inputs_2_float/example_2_float_1_cat_in_2_out.py +112 -0
- bencher/example/inputs_2_float/example_2_float_2_cat_in_2_out.py +122 -0
- bencher/example/inputs_2_float/example_2_float_3_cat_in_2_out.py +138 -0
- bencher/example/inputs_3_float/example_3_float_0_cat_in_2_out.py +111 -0
- bencher/example/inputs_3_float/example_3_float_1_cat_in_2_out.py +117 -0
- bencher/example/inputs_3_float/example_3_float_2_cat_in_2_out.py +124 -0
- bencher/example/inputs_3_float/example_3_float_3_cat_in_2_out.py +129 -0
- bencher/example/meta/generate_examples.py +124 -7
- bencher/example/meta/generate_meta.py +88 -40
- bencher/job.py +175 -12
- bencher/plotting/plot_filter.py +52 -17
- bencher/results/bench_result.py +119 -26
- bencher/results/bench_result_base.py +119 -10
- bencher/results/composable_container/composable_container_video.py +39 -12
- bencher/results/dataset_result.py +6 -200
- bencher/results/explorer_result.py +23 -0
- bencher/results/{hvplot_result.py → histogram_result.py} +3 -18
- bencher/results/holoview_results/__init__.py +0 -0
- bencher/results/holoview_results/bar_result.py +79 -0
- bencher/results/holoview_results/curve_result.py +110 -0
- bencher/results/holoview_results/distribution_result/__init__.py +0 -0
- bencher/results/holoview_results/distribution_result/box_whisker_result.py +73 -0
- bencher/results/holoview_results/distribution_result/distribution_result.py +109 -0
- bencher/results/holoview_results/distribution_result/scatter_jitter_result.py +92 -0
- bencher/results/holoview_results/distribution_result/violin_result.py +70 -0
- bencher/results/holoview_results/heatmap_result.py +319 -0
- bencher/results/holoview_results/holoview_result.py +346 -0
- bencher/results/holoview_results/line_result.py +240 -0
- bencher/results/holoview_results/scatter_result.py +107 -0
- bencher/results/holoview_results/surface_result.py +158 -0
- bencher/results/holoview_results/table_result.py +14 -0
- bencher/results/holoview_results/tabulator_result.py +20 -0
- bencher/results/laxtex_result.py +42 -35
- bencher/results/optuna_result.py +30 -115
- bencher/results/video_controls.py +38 -0
- bencher/results/video_result.py +39 -36
- bencher/results/video_summary.py +2 -2
- bencher/results/{plotly_result.py → volume_result.py} +29 -8
- bencher/utils.py +176 -30
- bencher/variables/inputs.py +122 -15
- bencher/video_writer.py +38 -2
- bencher/worker_job.py +34 -7
- {holobench-1.40.1.dist-info → holobench-1.42.0.dist-info}/METADATA +21 -25
- holobench-1.42.0.dist-info/RECORD +147 -0
- bencher/example/example_composable_container.py +0 -106
- bencher/example/example_levels2.py +0 -37
- bencher/example/inputs_1D/example_1_in_1_out.py +0 -62
- bencher/example/inputs_1D/example_1_in_2_out.py +0 -63
- bencher/example/inputs_1D/example_1_in_2_out_repeats.py +0 -61
- bencher/results/holoview_result.py +0 -787
- bencher/results/panel_result.py +0 -41
- holobench-1.40.1.dist-info/RECORD +0 -111
- {holobench-1.40.1.dist-info → holobench-1.42.0.dist-info}/WHEEL +0 -0
- {holobench-1.40.1.dist-info → holobench-1.42.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,117 @@
|
|
1
|
+
"""Demonstration of benchmarking with 3 float and 1 categorical input producing visually distinct patterns.
|
2
|
+
|
3
|
+
The categorical input has 2 conditions that create distinctly different surface shapes in 3D space.
|
4
|
+
"""
|
5
|
+
|
6
|
+
import random
|
7
|
+
import math
|
8
|
+
import bencher as bch
|
9
|
+
import holoviews as hv
|
10
|
+
|
11
|
+
random.seed(0)
|
12
|
+
|
13
|
+
|
14
|
+
class Pattern3DModel1Cat(bch.ParametrizedSweep):
|
15
|
+
"""Benchmark demonstrating 3D patterns with distinctive shapes based on 1 categorical setting."""
|
16
|
+
|
17
|
+
# Float input parameters
|
18
|
+
x_value = bch.FloatSweep(default=50, bounds=[0, 100], doc="X value parameter")
|
19
|
+
y_value = bch.FloatSweep(default=50, bounds=[0, 100], doc="Y value parameter")
|
20
|
+
z_value = bch.FloatSweep(default=50, bounds=[0, 100], doc="Z value parameter")
|
21
|
+
|
22
|
+
# Categorical input parameter - with 2 conditions
|
23
|
+
geometry_type = bch.StringSweep(["spherical", "cylindrical"], doc="Geometry model")
|
24
|
+
# Removed scaling_type and composition_type categoricals
|
25
|
+
|
26
|
+
# Output metrics
|
27
|
+
contrast = bch.ResultVar(units="ratio", doc="Secondary contrast measure")
|
28
|
+
intensity = bch.ResultVar(units="units", doc="Primary response intensity")
|
29
|
+
|
30
|
+
def __call__(self, **kwargs) -> dict:
|
31
|
+
"""Generate 3D responses with distinctly different patterns based on the geometry categorical input."""
|
32
|
+
self.update_params_from_kwargs(**kwargs)
|
33
|
+
|
34
|
+
# Normalize inputs to [0,1]
|
35
|
+
x = self.x_value / 100
|
36
|
+
y = self.y_value / 100
|
37
|
+
z = self.z_value / 100
|
38
|
+
|
39
|
+
# Calculate radial components based on geometry_type
|
40
|
+
if self.geometry_type == "spherical":
|
41
|
+
# Spherical geometry creates radial patterns from center
|
42
|
+
r = math.sqrt(x**2 + y**2 + z**2) / math.sqrt(3)
|
43
|
+
theta = math.atan2(y, x) / (2 * math.pi) + 0.5 # normalized [0,1]
|
44
|
+
phi = math.acos(z / max(0.001, math.sqrt(x**2 + y**2 + z**2))) / math.pi
|
45
|
+
else: # cylindrical
|
46
|
+
# Cylindrical geometry creates patterns based on distance from z-axis
|
47
|
+
r = math.sqrt(x**2 + y**2) / math.sqrt(2)
|
48
|
+
theta = math.atan2(y, x) / (2 * math.pi) + 0.5
|
49
|
+
phi = z # z directly affects the height
|
50
|
+
|
51
|
+
# Fixed to linear scaling (removed scaling_type categorical)
|
52
|
+
# Linear scaling creates more uniform patterns
|
53
|
+
scale_factor = 1.5 * r + 0.8 * phi + 0.5 * theta
|
54
|
+
scale_factor2 = 0.7 * r + 1.2 * phi + 0.9 * theta
|
55
|
+
|
56
|
+
# Create wave patterns
|
57
|
+
wave1 = math.sin(5 * math.pi * r) * math.cos(4 * math.pi * theta)
|
58
|
+
wave2 = math.sin(3 * math.pi * phi) * math.sin(6 * math.pi * r * theta)
|
59
|
+
|
60
|
+
# Create interference patterns
|
61
|
+
pattern1 = math.sin(7 * math.pi * (x + y + z) / 3)
|
62
|
+
pattern2 = math.cos(9 * math.pi * x * y * z)
|
63
|
+
|
64
|
+
# Fixed to additive composition (removed composition_type categorical)
|
65
|
+
# Additive creates smoother transitions
|
66
|
+
self.intensity = 0.6 * scale_factor + 0.3 * wave1 + 0.2 * pattern1 + 0.5
|
67
|
+
self.contrast = 0.4 * scale_factor2 + 0.5 * wave2 + 0.3 * pattern2 + 0.3
|
68
|
+
|
69
|
+
# Add minimal randomness (to maintain pattern visibility)
|
70
|
+
random_factor = random.uniform(0.98, 1.02)
|
71
|
+
self.intensity *= random_factor
|
72
|
+
self.contrast *= random_factor
|
73
|
+
|
74
|
+
# Keep values in a reasonable range
|
75
|
+
self.intensity = max(0.1, min(3.0, self.intensity))
|
76
|
+
self.contrast = max(0.1, min(3.0, self.contrast))
|
77
|
+
|
78
|
+
return super().__call__(**kwargs)
|
79
|
+
|
80
|
+
|
81
|
+
def example_3_float_1_cat_in_2_out(
|
82
|
+
run_cfg: bch.BenchRunCfg = None, report: bch.BenchReport = None
|
83
|
+
) -> bch.Bench:
|
84
|
+
"""Benchmark demonstrating 3D visual patterns based on 1 categorical setting.
|
85
|
+
|
86
|
+
Args:
|
87
|
+
run_cfg: Configuration for the benchmark run
|
88
|
+
report: Report to append the results to
|
89
|
+
|
90
|
+
Returns:
|
91
|
+
bch.Bench: The benchmark object
|
92
|
+
"""
|
93
|
+
if run_cfg is None:
|
94
|
+
run_cfg = bch.BenchRunCfg()
|
95
|
+
run_cfg.level = 5
|
96
|
+
run_cfg.repeats = 1 # Fewer repeats for a quicker benchmark
|
97
|
+
|
98
|
+
hv.opts.defaults(hv.opts.HeatMap(cmap="plasma", width=300, height=300, colorbar=True))
|
99
|
+
|
100
|
+
bench = Pattern3DModel1Cat().to_bench(run_cfg, report)
|
101
|
+
bench.plot_sweep(
|
102
|
+
title="3D Pattern Visualization (3 Float, 1 Categorical Variable)",
|
103
|
+
description="Response patterns with distinctive shapes based on 3D coordinates and 1 categorical setting",
|
104
|
+
post_description="""
|
105
|
+
Geometry Type: Spherical (radial from center) vs Cylindrical (distance from z-axis)
|
106
|
+
|
107
|
+
This example uses linear scaling and additive composition for pattern generation (fixed parameters).
|
108
|
+
2D slices of the 3D space show visually distinctive patterns that vary based on the geometry setting.
|
109
|
+
The intensity and contrast measures reveal different aspects of the underlying mathematical model.
|
110
|
+
""",
|
111
|
+
)
|
112
|
+
|
113
|
+
return bench
|
114
|
+
|
115
|
+
|
116
|
+
if __name__ == "__main__":
|
117
|
+
example_3_float_1_cat_in_2_out().report.show()
|
@@ -0,0 +1,124 @@
|
|
1
|
+
"""Demonstration of benchmarking with 3 float and 2 categorical inputs producing visually distinct patterns.
|
2
|
+
|
3
|
+
Each categorical input has 2 conditions that create distinctly different surface shapes in 3D space.
|
4
|
+
"""
|
5
|
+
|
6
|
+
import random
|
7
|
+
import math
|
8
|
+
import bencher as bch
|
9
|
+
import holoviews as hv
|
10
|
+
|
11
|
+
random.seed(0)
|
12
|
+
|
13
|
+
|
14
|
+
class Pattern3DModel2Cat(bch.ParametrizedSweep):
|
15
|
+
"""Benchmark demonstrating 3D patterns with distinctive shapes based on 2 categorical settings."""
|
16
|
+
|
17
|
+
# Float input parameters
|
18
|
+
x_value = bch.FloatSweep(default=50, bounds=[0, 100], doc="X value parameter")
|
19
|
+
y_value = bch.FloatSweep(default=50, bounds=[0, 100], doc="Y value parameter")
|
20
|
+
z_value = bch.FloatSweep(default=50, bounds=[0, 100], doc="Z value parameter")
|
21
|
+
|
22
|
+
# Categorical input parameters - each with 2 conditions
|
23
|
+
geometry_type = bch.StringSweep(["spherical", "cylindrical"], doc="Geometry model")
|
24
|
+
scaling_type = bch.StringSweep(["linear", "quadratic"], doc="Scaling behavior")
|
25
|
+
# Removed composition_type categorical
|
26
|
+
|
27
|
+
# Output metrics
|
28
|
+
contrast = bch.ResultVar(units="ratio", doc="Secondary contrast measure")
|
29
|
+
intensity = bch.ResultVar(units="units", doc="Primary response intensity")
|
30
|
+
|
31
|
+
def __call__(self, **kwargs) -> dict:
|
32
|
+
"""Generate 3D responses with distinctly different patterns based on categorical inputs."""
|
33
|
+
self.update_params_from_kwargs(**kwargs)
|
34
|
+
|
35
|
+
# Normalize inputs to [0,1]
|
36
|
+
x = self.x_value / 100
|
37
|
+
y = self.y_value / 100
|
38
|
+
z = self.z_value / 100
|
39
|
+
|
40
|
+
# Calculate radial components based on geometry_type
|
41
|
+
if self.geometry_type == "spherical":
|
42
|
+
# Spherical geometry creates radial patterns from center
|
43
|
+
r = math.sqrt(x**2 + y**2 + z**2) / math.sqrt(3)
|
44
|
+
theta = math.atan2(y, x) / (2 * math.pi) + 0.5 # normalized [0,1]
|
45
|
+
phi = math.acos(z / max(0.001, math.sqrt(x**2 + y**2 + z**2))) / math.pi
|
46
|
+
else: # cylindrical
|
47
|
+
# Cylindrical geometry creates patterns based on distance from z-axis
|
48
|
+
r = math.sqrt(x**2 + y**2) / math.sqrt(2)
|
49
|
+
theta = math.atan2(y, x) / (2 * math.pi) + 0.5
|
50
|
+
phi = z # z directly affects the height
|
51
|
+
|
52
|
+
# Apply scaling function
|
53
|
+
if self.scaling_type == "linear":
|
54
|
+
# Linear scaling creates more uniform patterns
|
55
|
+
scale_factor = 1.5 * r + 0.8 * phi + 0.5 * theta
|
56
|
+
scale_factor2 = 0.7 * r + 1.2 * phi + 0.9 * theta
|
57
|
+
else: # quadratic
|
58
|
+
# Quadratic scaling creates more concentrated effects
|
59
|
+
scale_factor = 1.5 * r**2 + 0.8 * phi**2 + 0.5 * theta
|
60
|
+
scale_factor2 = 0.7 * r**2 + 1.2 * phi**2 + 0.9 * theta
|
61
|
+
|
62
|
+
# Create wave patterns
|
63
|
+
wave1 = math.sin(5 * math.pi * r) * math.cos(4 * math.pi * theta)
|
64
|
+
wave2 = math.sin(3 * math.pi * phi) * math.sin(6 * math.pi * r * theta)
|
65
|
+
|
66
|
+
# Create interference patterns
|
67
|
+
pattern1 = math.sin(7 * math.pi * (x + y + z) / 3)
|
68
|
+
pattern2 = math.cos(9 * math.pi * x * y * z)
|
69
|
+
|
70
|
+
# Fixed to additive composition (removed composition_type categorical)
|
71
|
+
# Additive creates smoother transitions
|
72
|
+
self.intensity = 0.6 * scale_factor + 0.3 * wave1 + 0.2 * pattern1 + 0.5
|
73
|
+
self.contrast = 0.4 * scale_factor2 + 0.5 * wave2 + 0.3 * pattern2 + 0.3
|
74
|
+
|
75
|
+
# Add minimal randomness (to maintain pattern visibility)
|
76
|
+
random_factor = random.uniform(0.98, 1.02)
|
77
|
+
self.intensity *= random_factor
|
78
|
+
self.contrast *= random_factor
|
79
|
+
|
80
|
+
# Keep values in a reasonable range
|
81
|
+
self.intensity = max(0.1, min(3.0, self.intensity))
|
82
|
+
self.contrast = max(0.1, min(3.0, self.contrast))
|
83
|
+
|
84
|
+
return super().__call__(**kwargs)
|
85
|
+
|
86
|
+
|
87
|
+
def example_3_float_2_cat_in_2_out(
|
88
|
+
run_cfg: bch.BenchRunCfg = None, report: bch.BenchReport = None
|
89
|
+
) -> bch.Bench:
|
90
|
+
"""Benchmark demonstrating 3D visual patterns based on 2 categorical settings.
|
91
|
+
|
92
|
+
Args:
|
93
|
+
run_cfg: Configuration for the benchmark run
|
94
|
+
report: Report to append the results to
|
95
|
+
|
96
|
+
Returns:
|
97
|
+
bch.Bench: The benchmark object
|
98
|
+
"""
|
99
|
+
if run_cfg is None:
|
100
|
+
run_cfg = bch.BenchRunCfg()
|
101
|
+
run_cfg.level = 5
|
102
|
+
run_cfg.repeats = 1 # Fewer repeats for a quicker benchmark
|
103
|
+
|
104
|
+
hv.opts.defaults(hv.opts.HeatMap(cmap="plasma", width=300, height=300, colorbar=True))
|
105
|
+
|
106
|
+
bench = Pattern3DModel2Cat().to_bench(run_cfg, report)
|
107
|
+
bench.plot_sweep(
|
108
|
+
title="3D Pattern Visualization (3 Float, 2 Categorical Variables)",
|
109
|
+
description="Response patterns with distinctive shapes based on 3D coordinates and 2 categorical settings",
|
110
|
+
post_description="""
|
111
|
+
Geometry Type: Spherical (radial from center) vs Cylindrical (distance from z-axis)
|
112
|
+
Scaling Type: Linear (uniform effects) vs Quadratic (concentrated effects)
|
113
|
+
|
114
|
+
This example uses additive composition for pattern generation (fixed parameter).
|
115
|
+
2D slices of the 3D space show visually distinctive patterns that vary based on categorical settings.
|
116
|
+
The intensity and contrast measures reveal different aspects of the underlying mathematical model.
|
117
|
+
""",
|
118
|
+
)
|
119
|
+
|
120
|
+
return bench
|
121
|
+
|
122
|
+
|
123
|
+
if __name__ == "__main__":
|
124
|
+
example_3_float_2_cat_in_2_out().report.show()
|
@@ -0,0 +1,129 @@
|
|
1
|
+
"""Demonstration of benchmarking with 3 float and 3 categorical inputs producing visually distinct patterns.
|
2
|
+
|
3
|
+
Each categorical input has 2 conditions that create distinctly different surface shapes in 3D space.
|
4
|
+
"""
|
5
|
+
|
6
|
+
import random
|
7
|
+
import math
|
8
|
+
import bencher as bch
|
9
|
+
import holoviews as hv
|
10
|
+
|
11
|
+
random.seed(0)
|
12
|
+
|
13
|
+
|
14
|
+
class Pattern3DModel(bch.ParametrizedSweep):
|
15
|
+
"""Benchmark demonstrating 3D patterns with distinctive shapes based on categorical settings."""
|
16
|
+
|
17
|
+
# Float input parameters
|
18
|
+
x_value = bch.FloatSweep(default=50, bounds=[0, 100], doc="X value parameter")
|
19
|
+
y_value = bch.FloatSweep(default=50, bounds=[0, 100], doc="Y value parameter")
|
20
|
+
z_value = bch.FloatSweep(default=50, bounds=[0, 100], doc="Z value parameter")
|
21
|
+
|
22
|
+
# Categorical input parameters - each with 2 conditions
|
23
|
+
geometry_type = bch.StringSweep(["spherical", "cylindrical"], doc="Geometry model")
|
24
|
+
scaling_type = bch.StringSweep(["linear", "quadratic"], doc="Scaling behavior")
|
25
|
+
composition_type = bch.StringSweep(["additive", "multiplicative"], doc="How components combine")
|
26
|
+
|
27
|
+
# Output metrics
|
28
|
+
contrast = bch.ResultVar(units="ratio", doc="Secondary contrast measure")
|
29
|
+
intensity = bch.ResultVar(units="units", doc="Primary response intensity")
|
30
|
+
|
31
|
+
def __call__(self, **kwargs) -> dict:
|
32
|
+
"""Generate 3D responses with distinctly different patterns based on categorical inputs."""
|
33
|
+
self.update_params_from_kwargs(**kwargs)
|
34
|
+
|
35
|
+
# Normalize inputs to [0,1]
|
36
|
+
x = self.x_value / 100
|
37
|
+
y = self.y_value / 100
|
38
|
+
z = self.z_value / 100
|
39
|
+
|
40
|
+
# Calculate radial components based on geometry_type
|
41
|
+
if self.geometry_type == "spherical":
|
42
|
+
# Spherical geometry creates radial patterns from center
|
43
|
+
r = math.sqrt(x**2 + y**2 + z**2) / math.sqrt(3)
|
44
|
+
theta = math.atan2(y, x) / (2 * math.pi) + 0.5 # normalized [0,1]
|
45
|
+
phi = math.acos(z / max(0.001, math.sqrt(x**2 + y**2 + z**2))) / math.pi
|
46
|
+
else: # cylindrical
|
47
|
+
# Cylindrical geometry creates patterns based on distance from z-axis
|
48
|
+
r = math.sqrt(x**2 + y**2) / math.sqrt(2)
|
49
|
+
theta = math.atan2(y, x) / (2 * math.pi) + 0.5
|
50
|
+
phi = z # z directly affects the height
|
51
|
+
|
52
|
+
# Apply scaling function
|
53
|
+
if self.scaling_type == "linear":
|
54
|
+
# Linear scaling creates more uniform patterns
|
55
|
+
scale_factor = 1.5 * r + 0.8 * phi + 0.5 * theta
|
56
|
+
scale_factor2 = 0.7 * r + 1.2 * phi + 0.9 * theta
|
57
|
+
else: # quadratic
|
58
|
+
# Quadratic scaling creates more concentrated effects
|
59
|
+
scale_factor = 1.5 * r**2 + 0.8 * phi**2 + 0.5 * theta
|
60
|
+
scale_factor2 = 0.7 * r**2 + 1.2 * phi**2 + 0.9 * theta
|
61
|
+
|
62
|
+
# Create wave patterns
|
63
|
+
wave1 = math.sin(5 * math.pi * r) * math.cos(4 * math.pi * theta)
|
64
|
+
wave2 = math.sin(3 * math.pi * phi) * math.sin(6 * math.pi * r * theta)
|
65
|
+
|
66
|
+
# Create interference patterns
|
67
|
+
pattern1 = math.sin(7 * math.pi * (x + y + z) / 3)
|
68
|
+
pattern2 = math.cos(9 * math.pi * x * y * z)
|
69
|
+
|
70
|
+
# Combine components based on composition_type
|
71
|
+
if self.composition_type == "additive":
|
72
|
+
# Additive creates smoother transitions
|
73
|
+
self.intensity = 0.6 * scale_factor + 0.3 * wave1 + 0.2 * pattern1 + 0.5
|
74
|
+
self.contrast = 0.4 * scale_factor2 + 0.5 * wave2 + 0.3 * pattern2 + 0.3
|
75
|
+
else: # multiplicative
|
76
|
+
# Multiplicative creates sharper boundaries
|
77
|
+
self.intensity = 0.6 * scale_factor * (1 + 0.6 * wave1) * (1 + 0.4 * pattern1)
|
78
|
+
self.contrast = 0.4 * scale_factor2 * (1 + 0.8 * wave2) * (1 + 0.5 * pattern2)
|
79
|
+
|
80
|
+
# Add minimal randomness (to maintain pattern visibility)
|
81
|
+
random_factor = random.uniform(0.98, 1.02)
|
82
|
+
self.intensity *= random_factor
|
83
|
+
self.contrast *= random_factor
|
84
|
+
|
85
|
+
# Keep values in a reasonable range
|
86
|
+
self.intensity = max(0.1, min(3.0, self.intensity))
|
87
|
+
self.contrast = max(0.1, min(3.0, self.contrast))
|
88
|
+
|
89
|
+
return super().__call__(**kwargs)
|
90
|
+
|
91
|
+
|
92
|
+
def example_3_float_3_cat_in_2_out(
|
93
|
+
run_cfg: bch.BenchRunCfg = None, report: bch.BenchReport = None
|
94
|
+
) -> bch.Bench:
|
95
|
+
"""Benchmark demonstrating 3D visual patterns based on categorical settings.
|
96
|
+
|
97
|
+
Args:
|
98
|
+
run_cfg: Configuration for the benchmark run
|
99
|
+
report: Report to append the results to
|
100
|
+
|
101
|
+
Returns:
|
102
|
+
bch.Bench: The benchmark object
|
103
|
+
"""
|
104
|
+
if run_cfg is None:
|
105
|
+
run_cfg = bch.BenchRunCfg()
|
106
|
+
run_cfg.level = 5
|
107
|
+
run_cfg.repeats = 1 # Fewer repeats for a quicker benchmark
|
108
|
+
|
109
|
+
hv.opts.defaults(hv.opts.HeatMap(cmap="plasma", width=300, height=300, colorbar=True))
|
110
|
+
|
111
|
+
bench = Pattern3DModel().to_bench(run_cfg, report)
|
112
|
+
bench.plot_sweep(
|
113
|
+
title="3D Pattern Visualization (3 Float, 3 Categorical Variables)",
|
114
|
+
description="Response patterns with distinctive shapes based on 3D coordinates and categorical settings",
|
115
|
+
post_description="""
|
116
|
+
Geometry Type: Spherical (radial from center) vs Cylindrical (distance from z-axis)
|
117
|
+
Scaling Type: Linear (uniform effects) vs Quadratic (concentrated effects)
|
118
|
+
Composition Type: Additive (smooth transitions) vs Multiplicative (sharp boundaries)
|
119
|
+
|
120
|
+
2D slices of the 3D space show visually distinctive patterns that vary based on categorical settings.
|
121
|
+
The intensity and contrast measures reveal different aspects of the underlying mathematical model.
|
122
|
+
""",
|
123
|
+
)
|
124
|
+
|
125
|
+
return bench
|
126
|
+
|
127
|
+
|
128
|
+
if __name__ == "__main__":
|
129
|
+
example_3_float_3_cat_in_2_out().report.show()
|
@@ -2,13 +2,15 @@ import nbformat as nbf
|
|
2
2
|
from pathlib import Path
|
3
3
|
|
4
4
|
|
5
|
-
def convert_example_to_jupyter_notebook(
|
6
|
-
|
5
|
+
def convert_example_to_jupyter_notebook(
|
6
|
+
filename: str, output_path: str, repeats: int = None
|
7
|
+
) -> None:
|
7
8
|
source_path = Path(filename)
|
8
9
|
|
9
10
|
nb = nbf.v4.new_notebook()
|
10
11
|
title = source_path.stem
|
11
|
-
|
12
|
+
repeat_exr = f"bch.BenchRunCfg(repeats={repeats})" if repeats else ""
|
13
|
+
function_name = f"{source_path.stem}({repeat_exr})"
|
12
14
|
text = f"""# {title}"""
|
13
15
|
|
14
16
|
code = "%%capture\n"
|
@@ -34,17 +36,132 @@ bench.get_result().to_auto_plots()
|
|
34
36
|
]
|
35
37
|
output_path = Path(f"docs/reference/{output_path}/ex_{title}.ipynb")
|
36
38
|
output_path.parent.mkdir(parents=True, exist_ok=True)
|
37
|
-
|
39
|
+
# Add a newline character at the end to ensure proper end-of-file
|
40
|
+
notebook_content = nbf.writes(nb) + "\n"
|
41
|
+
output_path.write_text(notebook_content, encoding="utf-8")
|
38
42
|
|
39
43
|
|
40
44
|
if __name__ == "__main__":
|
45
|
+
# Examples with different numbers of categorical variables in increasing order
|
41
46
|
convert_example_to_jupyter_notebook(
|
42
|
-
"/workspaces/bencher/bencher/example/
|
47
|
+
"/workspaces/bencher/bencher/example/inputs_0_float/example_0_cat_in_2_out.py",
|
48
|
+
"inputs_0_float",
|
49
|
+
repeats=100,
|
43
50
|
)
|
51
|
+
|
44
52
|
convert_example_to_jupyter_notebook(
|
45
|
-
"/workspaces/bencher/bencher/example/
|
53
|
+
"/workspaces/bencher/bencher/example/inputs_0_float/example_1_cat_in_2_out.py",
|
54
|
+
"inputs_0_float",
|
46
55
|
)
|
47
56
|
|
48
57
|
convert_example_to_jupyter_notebook(
|
49
|
-
"/workspaces/bencher/bencher/example/
|
58
|
+
"/workspaces/bencher/bencher/example/inputs_0_float/example_2_cat_in_2_out.py",
|
59
|
+
"inputs_0_float",
|
50
60
|
)
|
61
|
+
|
62
|
+
convert_example_to_jupyter_notebook(
|
63
|
+
"/workspaces/bencher/bencher/example/inputs_0_float/example_3_cat_in_2_out.py",
|
64
|
+
"inputs_0_float",
|
65
|
+
)
|
66
|
+
|
67
|
+
# Examples with 1 float input plus varying categorical inputs
|
68
|
+
convert_example_to_jupyter_notebook(
|
69
|
+
"/workspaces/bencher/bencher/example/inputs_1_float/example_1_float_0_cat_in_2_out.py",
|
70
|
+
"inputs_1_float",
|
71
|
+
)
|
72
|
+
|
73
|
+
convert_example_to_jupyter_notebook(
|
74
|
+
"/workspaces/bencher/bencher/example/inputs_1_float/example_1_float_1_cat_in_2_out.py",
|
75
|
+
"inputs_1_float",
|
76
|
+
)
|
77
|
+
|
78
|
+
convert_example_to_jupyter_notebook(
|
79
|
+
"/workspaces/bencher/bencher/example/inputs_1_float/example_1_float_2_cat_in_2_out.py",
|
80
|
+
"inputs_1_float",
|
81
|
+
)
|
82
|
+
|
83
|
+
convert_example_to_jupyter_notebook(
|
84
|
+
"/workspaces/bencher/bencher/example/inputs_1_float/example_1_float_3_cat_in_2_out.py",
|
85
|
+
"inputs_1_float",
|
86
|
+
)
|
87
|
+
|
88
|
+
# Example with 2 float inputs plus categorical inputs
|
89
|
+
convert_example_to_jupyter_notebook(
|
90
|
+
"/workspaces/bencher/bencher/example/inputs_2_float/example_2_float_3_cat_in_2_out.py",
|
91
|
+
"inputs_2_float",
|
92
|
+
)
|
93
|
+
|
94
|
+
convert_example_to_jupyter_notebook(
|
95
|
+
"/workspaces/bencher/bencher/example/inputs_2_float/example_2_float_2_cat_in_2_out.py",
|
96
|
+
"inputs_2_float",
|
97
|
+
)
|
98
|
+
|
99
|
+
convert_example_to_jupyter_notebook(
|
100
|
+
"/workspaces/bencher/bencher/example/inputs_2_float/example_2_float_1_cat_in_2_out.py",
|
101
|
+
"inputs_2_float",
|
102
|
+
)
|
103
|
+
|
104
|
+
convert_example_to_jupyter_notebook(
|
105
|
+
"/workspaces/bencher/bencher/example/inputs_2_float/example_2_float_0_cat_in_2_out.py",
|
106
|
+
"inputs_2_float",
|
107
|
+
)
|
108
|
+
|
109
|
+
# Examples with 3 float inputs plus categorical inputs
|
110
|
+
convert_example_to_jupyter_notebook(
|
111
|
+
"/workspaces/bencher/bencher/example/inputs_3_float/example_3_float_3_cat_in_2_out.py",
|
112
|
+
"inputs_3_float",
|
113
|
+
)
|
114
|
+
|
115
|
+
convert_example_to_jupyter_notebook(
|
116
|
+
"/workspaces/bencher/bencher/example/inputs_3_float/example_3_float_2_cat_in_2_out.py",
|
117
|
+
"inputs_3_float",
|
118
|
+
)
|
119
|
+
|
120
|
+
convert_example_to_jupyter_notebook(
|
121
|
+
"/workspaces/bencher/bencher/example/inputs_3_float/example_3_float_1_cat_in_2_out.py",
|
122
|
+
"inputs_3_float",
|
123
|
+
)
|
124
|
+
|
125
|
+
convert_example_to_jupyter_notebook(
|
126
|
+
"/workspaces/bencher/bencher/example/inputs_3_float/example_3_float_0_cat_in_2_out.py",
|
127
|
+
"inputs_3_float",
|
128
|
+
)
|
129
|
+
|
130
|
+
convert_example_to_jupyter_notebook(
|
131
|
+
"/workspaces/bencher/bencher/example/inputs_0D/example_0_in_1_out.py", "0D", repeats=100
|
132
|
+
)
|
133
|
+
|
134
|
+
convert_example_to_jupyter_notebook(
|
135
|
+
"/workspaces/bencher/bencher/example/inputs_0D/example_0_in_2_out.py", "0D", repeats=100
|
136
|
+
)
|
137
|
+
|
138
|
+
# Other 1D examples
|
139
|
+
convert_example_to_jupyter_notebook(
|
140
|
+
"/workspaces/bencher/bencher/example/inputs_1D/example_1_int_in_1_out.py", "1D"
|
141
|
+
)
|
142
|
+
|
143
|
+
convert_example_to_jupyter_notebook(
|
144
|
+
"/workspaces/bencher/bencher/example/inputs_1D/example_1_int_in_2_out.py", "1D"
|
145
|
+
)
|
146
|
+
|
147
|
+
convert_example_to_jupyter_notebook(
|
148
|
+
"/workspaces/bencher/bencher/example/inputs_1D/example_1_int_in_2_out_repeats.py", "1D"
|
149
|
+
)
|
150
|
+
|
151
|
+
convert_example_to_jupyter_notebook(
|
152
|
+
"/workspaces/bencher/bencher/example/inputs_1D/example_1_cat_in_2_out_repeats.py", "1D"
|
153
|
+
)
|
154
|
+
|
155
|
+
convert_example_to_jupyter_notebook(
|
156
|
+
"/workspaces/bencher/bencher/example/inputs_2D/example_2_cat_in_4_out_repeats.py", "1D"
|
157
|
+
)
|
158
|
+
|
159
|
+
convert_example_to_jupyter_notebook(
|
160
|
+
"/workspaces/bencher/bencher/example/example_levels.py", "Levels"
|
161
|
+
)
|
162
|
+
|
163
|
+
# todo, enable
|
164
|
+
# convert_example_to_jupyter_notebook(
|
165
|
+
# "/workspaces/bencher/bencher/example/example_composable_container_video.py",
|
166
|
+
# "Media",
|
167
|
+
# )
|