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 in param_bounds (typically driver_spec.bounds), mutating demographic_model.model_base_params[name].bounds in place.

Only parameters explicitly present in param_bounds are affected; any parameter not mentioned keeps its default, type-determined bounds (see tracts.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 as start_params interval bounds). Accepts a Mapping or a pydantic model (e.g. ParamBoundsConfig). For either, any key that isn’t a parameter of demographic_model raises, to catch typos. Parameters absent from param_bounds are left unchanged.

  • demographic_model (ParametrizedDemography) – The demographic model whose parameter bounds are narrowed in place.

Raises:
  • KeyError – If param_bounds (given as a Mapping or pydantic model) specifies a name that is not a parameter of demographic_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_bounds also accepts any other attribute-style object (mirroring parse_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.