Module

class pmrf.modules.Module(*, name: str | None = None, metadata: Any = None)

Bases: Module

Base 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 name collapses 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, with metadata and a readable repr that 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() and pmrf.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.R and b.R. Object identity is not tracked, because JAX transformations rebuild objects. To share a parameter, inject it once into a builder (see pmrf.models.AbstractBuilder and pmrf.materials.Substrate), or tie the copies together with pmrf.tie().

metadata: Any = None

Arbitrary metadata stored alongside the module.

name: str | None = None

A name for the module.