_models#

cultivars.engine._internals._models = <module 'cultivars.engine._internals._models' from '/home/runner/work/cultivars/cultivars/src/cultivars/engine/_internals/_models.py'>[source]#

Protected base classes for model specifications and fitted results.

Two hierarchies live here, and they are deliberately separate.

Results inherit a single linear chain of field bases – _Result then _MeanResult – because multiple slotted dataclass bases that each declare fields raise TypeError: multiple bases have instance lay-out conflict. Anything optional is a behavior mixin with __slots__ = () and no fields of its own; the concrete result declares the attribute the mixin reads.

Model specifications inherit _ModelBase, which owns endog validation and the length check. Every family base in this subpackage descends from it, so no public constructor re-implements either.

A family base also owns its estimation: _build_objective assembles the optimizer surface from the validated specification, and _fit_family runs it and packs the raw outputs into a record from cultivars._internals._fits. The fit records carry no estimation logic of their own, so the specification is never destructured into a foreign call signature.

These bases implement the structural contracts in cultivars._core._protocols without importing them: the protocols are duck-typed, so the relationship is checked by isinstance at runtime and by mypy statically, with no import edge in either direction.