Theory bridge¶
didactic.theory._theory.build_theory_spec ¶
build_theory_spec(cls: type[Model]) -> TheorySpec
Build a panproto-compatible Theory spec dict for a Model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
type[Model]
|
A Model subclass with |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dict shaped to be deserialised by panproto's Rust core into
a |
Notes
The dict only encodes information available on the didactic side. The
panproto core may further validate the shape and reject malformed
specs; in that case, the caller surfaces a panproto.GatError.
See Also
build_theory : produces a real panproto.Theory from this spec.
didactic.theory._theory.build_theory ¶
Materialise a panproto.Theory from a Model class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cls
|
type
|
A Model subclass. |
required |
Returns:
| Type | Description |
|---|---|
Theory
|
The Theory produced by |
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
GatError
|
If panproto rejects the spec; usually a sign that didactic's translation is producing a malformed dict. |
Notes
Single inheritance flattens transparently because the metaclass
walks the full MRO when collecting field specs; the resulting
Theory already includes every inherited field. Multiple
inheritance triggers a real panproto.colimit_theories call,
which validates that the merge is consistent and is the categorical
pushout of the two branches over their shared ancestor.
This call is the only place in didactic proper that imports
panproto. Doing it lazily lets the rest of the package be
authored and unit-tested without panproto installed.