Module (pmrf.Module)
- class pmrf.Module(*, name: str | None = None, metadata: Any = None)
Bases:
ModuleBase class for parameter-aware objects in ParamRF.
A module is an immutable JAX PyTree that may contain ParamRF parameters, RF models, and other modules. Subclassing it says the object takes part in three things:
Naming. A module’s
namecollapses the path to its left into a namespace, which parameter names (pmrf.params()) depend on.Field validation.
pmrf.modules.validate()rejects raw float JAX arrays in its fields, which are ambiguous between free and fixed parameters.A shared base class for
pmrf.Model, losses, likelihoods, kernels, materials and evaluators, withmetadataand a readablereprthat shows parameters in declared space.
It has no public methods: operations that make equal sense on any collection of models and parameters are free functions, such as
pmrf.update()andpmrf.tie()(ADR-0002).Passing the same instance to two sibling fields does not share it. A module is a JAX PyTree, and each path holds its own copy of the leaves, so
prf.params(Two(a=Resistor(R=p), b=Resistor(R=p)))gives two independent parameters,a.Randb.R. Object identity is not tracked, because JAX transformations rebuild objects. To share a parameter, inject it once into a builder (seepmrf.models.AbstractBuilderandpmrf.materials.Substrate), or tie the copies together withpmrf.tie().- metadata: Any = None
Arbitrary metadata stored alongside the module.
- name: str | None = None
A name for the module.