Component Base Class
- class tabascal.components.Component[source]
Base class for all tabascal components
- build_constants() Dict[str, Any][source]
Return arrays that do not change during the forward pass.
Returns a dict of array_name -> array_value. These will be stored in constants as “_c/<ClassName>/array_name” by Model.__init__.
- require_double(config: Any) None[source]
Raise if this
requires_doublecomponent is run in single precision.Some components only work in double precision: the SGP4/phase trajectory components (differentiable orbits). Those set
requires_double = Trueand call this at the top ofsetupso they fail with a clear message under single precision instead of producing silently-wrong fp32 results. Driven by therequires_doubleflag so it stays in sync with the run-time preflight.
- validate_state(state: Dict[str, Any]) None[source]
Raise if a declared required input is not yet in the model state.
Only the keys of
stateare meaningful here: this runs at assembly time, where the values are placeholders for keys the model supplies itself. Called for each component in turn byvalidate_component_order().
- exception tabascal.components.ComponentOrderError[source]
model.componentsis incomplete or in the wrong dependency order.
- exception tabascal.components.MissingStateInput(component: str, key: str, message: str)[source]
A component declares a required input that is not in the model state.
Carries the component and key so the caller can say why it is missing – see
validate_component_order().
- tabascal.components.component_outputs(component) List[str][source]
The state keys a component writes.
state_outputsis whatModelactually merges into the state, so it wins oncesetuphas run. Before that – or for a component checked without an observation to set it up against – the class-leveloutput_shapesdeclaration is the same list.
- tabascal.components.component_ref(component) str[source]
The
"module:Class"string a component is written as in a config.
- tabascal.components.in_tree_components() Dict[str, type][source]
Every concrete component shipped with tabascal, keyed by config reference.
The keys are the
"module:Class"stringsmodel.componentsis written in, so they can be quoted straight back at the user. Abstract bases are left out – they cannot be listed in a config.
- tabascal.components.is_class(obj: Any) bool[source]
Whether
objreally is a class, on every supported Python.isinstance(obj, type)is not enough to guard anissubclasscall. Up to Python 3.10 a PEP 585 alias such asnp.ndarray[Any, np.dtype[Any]]proxies__class__to its origin, so it passes that check and then makesissubclassraiseTypeError: issubclass() arg 1 must be a class. CPython removed the proxy in 3.11 (gh-88912), which is why the module scan below only ever broke on the 3.10 floor – and it scans real module namespaces, wherenumpy.typing.NDArraywas exactly such an alias.type(obj)is never proxied, so asking whether the real metaclass is a metaclass is stable across versions.
- tabascal.components.state_key_producers() Dict[str, List[str]][source]
Map each state key to the in-tree components that write it.
- tabascal.components.validate_component_order(components: Sequence[Any], initial_state_keys: Iterable[str] = ()) None[source]
Check a
model.componentslist against the components’ declarations.Walks the list in order, tracking which state keys exist by the time each component runs –
initial_state_keysplus the outputs of everything before it – and raisesComponentOrderErroron the first component whoserequired_inputsare not all there. Runs on constructed components whether or not they have been set up, so the whole list is checked before any of it is traced; without it a missing or mis-ordered component surfaced only as aKeyErroron a state key from inside the JIT-ed forward pass.