myClorm
Convert Python values and typed records to and from Clingo symbols.
cltopy
cached
¶
cltopy(func, target_type=Any)
Decode a Clingo symbol as target_type or one of its union members.
symbol = clingo.symbol.parse_term('(1,("two",(3,())))') cltopy(symbol, list[int | str]) ImmutableList([1, 'two', 3])
findInControl
¶
Return control atoms that decode as target_type.
findInModel
¶
findInModel(model: Model, target_type: Any = Any, atoms: bool = True, theory: bool = True) -> dict[Symbol, Any]
Return model symbols that decode as target_type.
findInPropagateInit
¶
Return decoded propagator atoms mapped to their solver literals.
pytocl
¶
pytocl(v, target_type=None)
Encode a Python value as a Clingo symbol.
Dataclasses, NamedTuples, and annotated classes use their lower-camel-case
class name as the predicate name. target_type selects a type or union.
symbol = pytocl([1, "two", 3]) print(symbol) (1,("two",(3,())))