param
- pmrf.parameters.param(*, default: Any = <dataclasses._MISSING_TYPE object>, as_free: bool = False, as_fixed: bool = False, constraint: AbstractConstraint | None = None, scale: float | None = None, **kwargs) Any
A field specifier for registering parameters within a model.
This specifier can be used when declaring custom models inheriting from pmrf.Model.
It is used to register the parameter when a model is constructed, so it is listed by
pmrf.params(). It can also be used to enforce constraints, scaling, bounds and variability within the model itself.constraint is the parameter’s validity, such as a positive width: it always holds. A range the value brings, such as
pmrf.Bounded(), is intersected with it, and a prior is truncated to the result and renormalised.This simply creates a pmrf.field with a pmrf.as_param converter.
Example
Declaring a parameter with a positive constraint and built-in scale:
import pmrf as prf from pmrf.parameters.constraints import Positive class RC(prf.Module): R: prf.Param = prf.param(constraint=Positive()) C: prf.Param = prf.param(constraint=Positive(), scale=1e-12) rc = RC(1.0, 2.0) rc.C.value # 2.0, in pF rc.C.physical_value # 2e-12 RC(1.0, prf.Unconstrained(2.0, scale=1e-9)).C.physical_value # 2e-09: an explicit scale overrides the field's RC(-1.0, 2.0) # ValueError: out of bounds
- Parameters:
default (Any, optional) – The default value of the parameter.
constraint (Optional[AbstractConstraint], optional) – The constraint to apply to the parameter, in declared space. See
pmrf.parameters.constraints.scale (float, optional) – The units values of this field are written in, by default None (1.0). A parameter passed with its own scale keeps it.
as_free (bool, optional) – Whether to enforce that the value is a variable parameter. If False, incoming values will keep the variability (e.g. constants will remain constants). If True, all values will be co-erced into variable parameters.
as_fixed (bool, optional) – Whether to enforce that the value is a fixed parameter. If False, incoming values will keep the variability (e.g. constants will remain constants). If True, all values will be wrapped in
pmrf.Fixed().**kwargs – Additional key-word arguments to pass to the general
pmrf.field()specifier.
- Returns:
An equinox field with a built-in converter for parameter rules.
- Return type:
Any