constraints.project_bounds

constraints.project_bounds(free_params, metadata)

Clamp free_params to per-parameter bounds declared in metadata.

Reads the bounds field of each Parameter (set at construction time as Scalar(v, bounds=(lo, hi)) or Vector(v, bounds=(lo, hi))). Either bound may be None to leave that side unconstrained.

Parameters

Name Type Description Default
free_params dict[str, Array] Current name-keyed parameter arrays. required
metadata dict[str, Parameter] Name-keyed Parameter objects carrying bounds info. required

Returns

Name Type Description
dict[str, Array] A new dict with each array clipped to its declared bounds.
dict[str, Array] Parameters without bounds are returned unchanged.