cfx.refs¶
Field and component reference proxies.
Accessing a field or component on a Config class (not an instance)
returns a FieldRef that records the dotpath to that attribute. These
references are passed to Alias and Mirror at view class definition time
so that paths are validated against the schema immediately, before any
instance exists.
Chaining attribute access extends the path one step at a time:
CalibrationConfig.psf_fitting.kernel_estimate
# → FieldRef("psf_fitting.kernel_estimate")
Classes¶
A reference to a field on a |
|
Descriptor installed on a |
Module Contents¶
- class cfx.refs.FieldRef(path, resolved_cls)[source]¶
A reference to a field on a
Configclass.Obtained by accessing a field or component as a class attribute rather than on an instance. Attribute chains are validated against the schema at definition time — a typo in the path raises
AttributeErrorimmediately, not at the first runtime access.Pass a
FieldReftoAliasorMirrorinstead of a plain string to keep paths refactorable via normal IDE rename and go-to-definition tools.Examples
>>> from cfx import Config, Field, Alias >>> class Inner(Config): ... x: float = Field(1.0, "x value") >>> class Outer(Config, components=[Inner]): ... pass >>> Outer.inner.x FieldRef(...) >>> Alias(Outer.inner.x) <...Alias object at ...>
- class cfx.refs.ComponentRef(confid, cls)[source]¶
Descriptor installed on a
Configclass for each component slot.Installed automatically by
_ConfigTypeafter_nested_classesis built. Returns aFieldRefon class-level access so component paths can be used inAliasandMirrordeclarations. On instance access returns the stored sub-config instance as normal.- confid¶
- cls¶