bencher.variables.parametrised_sweep
Attributes
Classes
Parent class for all Sweep types that need a custom hash |
Module Contents
- bencher.variables.parametrised_sweep._input_result_cache: dict[tuple, _InputResult]
- class bencher.variables.parametrised_sweep.ParametrizedSweep(**params)
Bases:
param.ParameterizedParent class for all Sweep types that need a custom hash
- static param_hash(param_type: param.Parameterized, hash_value: bool = True) int
A custom hash function for parametrised types with options for hashing the value of the type and hashing metadata
- Parameters:
param_type (Parameterized) – A parameter
hash_value (bool, optional) – use the value as part of the hash. Defaults to True.
hash_meta (#) – use metadata as part of the hash. Defaults to False.
- Returns:
a hash
- Return type:
int
- hash_persistent() str
A hash function that avoids the PYTHONHASHSEED ‘feature’ which returns a different hash value each time the program is run
- update_params_from_kwargs(**kwargs) None
Given a dictionary of kwargs, set the parameters of the passed class ‘self’ to the values in the dictionary.
- classmethod get_input_and_results(include_name: bool = False) tuple[dict, dict]
Get dictionaries of input parameters and result parameters
- Parameters:
cls – A parametrised class
include_name (bool) – Include the name parameter that all parametrised classes have. Default False
- Returns:
A tuple containing the inputs and result parameters as dictionaries
- Return type:
tuple[dict, dict]
- get_inputs_as_dict() dict
Get the key:value pairs for all the input variables
- get_results_values_as_dict(holomap=None) dict
Get a dictionary of result variables with the name and the current value
- classmethod get_inputs_only() list[param.Parameter]
Return a list of input parameters
- Returns:
A list of input parameters
- Return type:
list[param.Parameter]
- static filter_fn(item, p_name)
- classmethod get_input_defaults(override_defaults: list | None = None) list[tuple[param.Parameter, Any]]
- classmethod get_input_defaults_override(**kwargs) dict[str, Any]
- classmethod get_results_only() list[param.Parameter]
Return a list of result parameters
- Returns:
A list of result parameters
- Return type:
list[param.Parameter]
- classmethod get_inputs_as_dims(compute_values=False, remove_dims: str | list[str] | None = None) list[holoviews.Dimension]
- to_dynamic_map(callback=None, name=None, remove_dims: str | list[str] | None = None, result_var: str | None = None) holoviews.DynamicMap
- to_gui(result_var: str | None = None, **kwargs)
- to_holomap(callback, remove_dims: str | list[str] | None = None) holoviews.DynamicMap
- __call__(**kwargs) dict
Dispatch to benchmark() if overridden, otherwise use legacy path.
- Returns:
a dictionary with all the result variables as named key value pairs.
- Return type:
dict
- benchmark()
Override this with your benchmark logic.
When called, all sweep parameters (self.x, etc.) are already set. Set result variables (self.result, etc.) directly on self. No need to call update_params_from_kwargs or super().__call__().
- plot_hmap(**kwargs)
- to_bench(run_cfg=None, report=None, name=None)
Create a Bench instance from this ParametrizedSweep.
- to_optimize(n_trials=100, run_cfg=None, **kwargs)
Create a Bench and run optimization in one call.
- Parameters:
n_trials – Number of optuna trials.
run_cfg – Optional BenchRunCfg.
**kwargs – Forwarded to
Bench.optimize().
- Returns:
OptimizeResult wrapping the completed study.
- to_bench_runner(run_cfg=None, name=None)
Create a BenchRunner instance from this ParametrizedSweep.
- Enables fluent chaining like:
MyConfig().to_bench_runner().add(func).run(subsampling_divisions=2, max_subsampling_divisions=4)