|
46 | 46 | class Bench(BenchPlotServer): |
47 | 47 | def __init__( |
48 | 48 | self, |
49 | | - bench_name: str = None, |
50 | | - worker: Callable | ParametrizedSweep = None, |
51 | | - worker_input_cfg: ParametrizedSweep = None, |
52 | | - run_cfg: BenchRunCfg = None, |
53 | | - report: BenchReport = None, |
| 49 | + bench_name: str | None = None, |
| 50 | + worker: Callable | ParametrizedSweep | None = None, |
| 51 | + worker_input_cfg: ParametrizedSweep | None = None, |
| 52 | + run_cfg: BenchRunCfg | None = None, |
| 53 | + report: BenchReport | None = None, |
54 | 54 | ) -> None: |
55 | 55 | """Create a new Bench object for benchmarking a worker function with parametrized inputs. |
56 | 56 |
|
@@ -146,7 +146,9 @@ def add_plot_callback(self, callback: Callable[[BenchResult], pn.panel], **kwarg |
146 | 146 | self.plot_callbacks.append(partial(callback, **kwargs)) |
147 | 147 |
|
148 | 148 | def set_worker( |
149 | | - self, worker: Callable | ParametrizedSweep, worker_input_cfg: ParametrizedSweep = None |
| 149 | + self, |
| 150 | + worker: Callable | ParametrizedSweep, |
| 151 | + worker_input_cfg: ParametrizedSweep | None = None, |
150 | 152 | ) -> None: |
151 | 153 | """Set the benchmark worker function and its input configuration. |
152 | 154 |
|
@@ -174,15 +176,15 @@ def set_worker( |
174 | 176 | def sweep_sequential( |
175 | 177 | self, |
176 | 178 | title: str = "", |
177 | | - input_vars: List[ParametrizedSweep] = None, |
178 | | - result_vars: List[ParametrizedSweep] = None, |
179 | | - const_vars: List[ParametrizedSweep] = None, |
180 | | - optimise_var: ParametrizedSweep = None, |
181 | | - run_cfg: BenchRunCfg = None, |
| 179 | + input_vars: List[ParametrizedSweep] | None = None, |
| 180 | + result_vars: List[ParametrizedSweep] | None = None, |
| 181 | + const_vars: List[ParametrizedSweep] | None = None, |
| 182 | + optimise_var: ParametrizedSweep | None = None, |
| 183 | + run_cfg: BenchRunCfg | None = None, |
182 | 184 | group_size: int = 1, |
183 | 185 | iterations: int = 1, |
184 | | - relationship_cb: Callable = None, |
185 | | - plot_callbacks: List[Callable] | bool = None, |
| 186 | + relationship_cb: Callable | None = None, |
| 187 | + plot_callbacks: List[Callable] | bool | None = None, |
186 | 188 | ) -> List[BenchResult]: |
187 | 189 | """Run a sequence of benchmarks by sweeping through groups of input variables. |
188 | 190 |
|
@@ -234,17 +236,17 @@ def sweep_sequential( |
234 | 236 |
|
235 | 237 | def plot_sweep( |
236 | 238 | self, |
237 | | - title: str = None, |
238 | | - input_vars: List[ParametrizedSweep] = None, |
239 | | - result_vars: List[ParametrizedSweep] = None, |
240 | | - const_vars: List[ParametrizedSweep] = None, |
241 | | - time_src: datetime = None, |
242 | | - description: str = None, |
243 | | - post_description: str = None, |
| 239 | + title: str | None = None, |
| 240 | + input_vars: List[ParametrizedSweep] | None = None, |
| 241 | + result_vars: List[ParametrizedSweep] | None = None, |
| 242 | + const_vars: List[ParametrizedSweep] | None = None, |
| 243 | + time_src: datetime | None = None, |
| 244 | + description: str | None = None, |
| 245 | + post_description: str | None = None, |
244 | 246 | pass_repeat: bool = False, |
245 | 247 | tag: str = "", |
246 | | - run_cfg: BenchRunCfg = None, |
247 | | - plot_callbacks: List[Callable] | bool = None, |
| 248 | + run_cfg: BenchRunCfg | None = None, |
| 249 | + plot_callbacks: List[Callable] | bool | None = None, |
248 | 250 | sample_order: SampleOrder = SampleOrder.INORDER, |
249 | 251 | ) -> BenchResult: |
250 | 252 | """The all-in-one function for benchmarking and results plotting. |
@@ -439,7 +441,7 @@ def run_sweep( |
439 | 441 | self, |
440 | 442 | bench_cfg: BenchCfg, |
441 | 443 | run_cfg: BenchRunCfg, |
442 | | - time_src: datetime = None, |
| 444 | + time_src: datetime | None = None, |
443 | 445 | sample_order: SampleOrder = SampleOrder.INORDER, |
444 | 446 | ) -> BenchResult: |
445 | 447 | """Execute a benchmark sweep based on the provided configuration. |
@@ -538,7 +540,7 @@ def cache_results(self, bench_res: BenchResult, bench_cfg_hash: str) -> None: |
538 | 540 | """Cache benchmark results to disk using the config hash as key.""" |
539 | 541 | self._collector.cache_results(bench_res, bench_cfg_hash, self.bench_cfg_hashes) |
540 | 542 |
|
541 | | - # def show(self, run_cfg: BenchRunCfg = None, pane: pn.panel = None) -> None: |
| 543 | + # def show(self, run_cfg: BenchRunCfg | None = None, pane: pn.panel = None) -> None: |
542 | 544 | # """Launch a web server with plots of the benchmark results. |
543 | 545 | # |
544 | 546 | # This method starts a Panel web server to display the benchmark results interactively. |
|
0 commit comments