schrodinger.models.paramtools module¶
- schrodinger.models.paramtools.selective_set_value(src_model, dest_model, *, exclude=())[source]¶
Set the value of
dest_model
to the value ofsrc_model
, excluding any params specified byexclude
.- Parameters
src_model (
CompoundParam
) – The param to take values from.dest_model (iterator[Param]) – The param to apply values to.
exclude – An iterator of abstract params specifying values to ignore when applying src_model to dest_model.
- schrodinger.models.paramtools.map_subparams(map_func, compound_param, subparam_type)[source]¶
Find all subparams of type
subparam_type
incompound_param
and applymap_func
to it. Thecompound_param
will be modified in place.An example:
class Model(parameters.CompoundParam): workflow_runtimes: List[float] total_idle_time: float min_max_runtimes: Tuple[float, float] = None model = Model(workflow_runtimes = [60, 120, 180], total_idle_time=90, min_max_runtimes=(60,180)) def seconds_to_minutes(seconds): return seconds/60 map_subparams(seconds_to_minutes, model, subparam_type=float) model.workflow_runtimes # [1, 2, 3] model.total_idle_time # 1.5 model.min_max_runtimes # (1, 3)
Optionally, the map_func may accept a second argument of abstract_param. This may be useful in error messages or debugging. Example:
def seconds_to_minutes(seconds, abstract_param): if seconds is None: print(f'{abstract_subparam} was not set.') return None return seconds/60
Note that the argument must be named ‘abstract_param’ for it to get picked up.