tracts.driver_utils.parse_param_bounds#
- parse_param_bounds(param_bounds, demographic_model)#
Narrows each model parameter’s admissible bounds according to the
"min:max"intervals given inparam_bounds(typicallydriver_spec.bounds), mutatingdemographic_model.model_base_params[name].boundsin place.Only parameters explicitly present in
param_boundsare affected; any parameter not mentioned keeps its default, type-determined bounds (seetracts.demography.parameter.ParamType). A given bound is intersected with (not substituted for) the parameter’s current bounds, so it can only narrow the admissible region, never widen it beyond what the parameter’s type already allows (e.g. a RATE parameter can be narrowed within (0, 1), but not widened past it).- Parameters:
param_bounds – An object with an entry per parameter to narrow, each value a
"min:max"string (same format asstart_paramsinterval bounds). Accepts aMappingor a pydantic model (e.g.ParamBoundsConfig). For either, any key that isn’t a parameter ofdemographic_modelraises, to catch typos. Parameters absent fromparam_boundsare left unchanged.demographic_model (
ParametrizedDemography) – The demographic model whose parameter bounds are narrowed in place.
- Raises:
KeyError – If
param_bounds(given as aMappingor pydantic model) specifies a name that is not a parameter ofdemographic_model.ValueError – If a bound is not of the form
"min:max", or if the requested interval does not overlap the parameter’s current (type-determined) bounds.
Notes
- Return type:
None
param_boundsalso accepts any other attribute-style object (mirroringparse_start_params’s flexibility, mainly for testing): in that case only names that match an actual model parameter are read, and other attributes present on the object are ignored, since there is no reliable way to enumerate “all” attributes of an arbitrary object.