cottax.consumers.declaration¶
Declaring a model: functions wrapped where they are written or used, and the nodes they declare. A value written where a place is due becomes a given boundary input, and a tag on a node or a variable is carried into the Declared.
- class Conventions(reads: , tuple[~cottax.consumers.declaration.interface_types.PlaceWithValue, ...]]=ParameterReads(by_name=True), term: , ~cottax.consumers.declaration.interface_types.PlaceWithValue | None]=<function term_of>, per_place: , dict]=<function per_place_of>)[source]¶
Bases:
FrozenWhat a declaring part’s arguments mean, in three shapes, each a callable and cottax’s by default, so a study changes one: Conventions(term=my_term), my_term calling term_of for what it does not read itself. Held as a declaring part’s conventions, and asked through its methods of the same names (parameter_reads, term, per_place).
- reads: Callable[..., tuple[PlaceWithValue, ...]] = ParameterReads(by_name=True)¶
the reads of the function of, one per parameter in order: reads as written (a mapping by parameter, or a tuple of every one), read_in a rule per name, a value minted at given(parameter).
- Type:
reads(parameters, reads, read_in, *, place, given, of)
- term[V: Place](written: Any, *, place: Callable[[Any], V], value_at: PlaceToPlace[V])¶
term(x, written, *, place, value_at): what is written where a place about x is due: None for zero, a value at value_at(x), or a place.
- Return type:
Optional[PlaceWithValue[V]]
- Shipped(by_name: bool = True)[source]¶
cottax’s conventions, a parameter read at its own name unless by_name is off.
- Return type:
- class ParameterReads(by_name: bool = True)[source]¶
Bases:
Frozencottax’s reading of a function’s reads (reads_of), a parameter reads omits read at its own name unless by_name is off.
- by_name: bool = True¶
- term_of[V: Place](x: V, written: Any, *, place: Callable[[Any], V], value_at: PlaceToPlace[V])[source]¶
What is written where a place is due, about x: zero (None), a value (a place minted by value_at off x, given it), or a place; tagged or not, as a read is.
- Return type:
Optional[PlaceWithValue[V]]
- per_place_of[V: Place](among: tuple[V, ...], written: Any, *, place: Callable[[Any], V])[source]¶
What is written for each of among: a mapping by name, or one thing for the one place there is.
- Return type:
dict[V,Any]
- class Description[source]¶
Bases:
FrozenA function described rather than given: what a wrapper needs of it, its parameters in order. Its node is implemented by the description (a RepoRef to code elsewhere, say), which no backend runs until one resolves it.
- parameters: AbstractVar[tuple[str, ...]]¶
abstract to ABC until a subclass binds the name, and absent on a class that declares it as a field.
- Type:
What the level binds in place of the annotation
- class Unimplemented(parameters: tuple[str, ...])[source]¶
Bases:
DescriptionA function yet to be written: its parameters, and nothing else. Its node has no implementation.
- parameters: tuple[str, ...]¶
- class Explicit[N: Label, V: Place](fn: Body, function_reads: tuple[PlaceWithValue[V], ...], outputs: tuple[V, ...], *, output_tags: Tags[V] = {})[source]¶
Bases:
Wrapper[N,V],Generic[N,V]A function computing its outputs, returned in that order.
- terms: AbstractVar[tuple[Optional[PlaceWithValue[V]], ...]] = ()¶
What else it writes where a place is due, each a place (with the value where one was written) or None for zero: a constraint’s bounds or targets; none for most.
- property function_outputs: tuple[V, ...]¶
abstract to ABC until a subclass binds the name, and absent on a class that declares it as a field.
- Type:
What the level binds in place of the annotation
- nodes(at: N)[source]¶
What this declares, bound at at and at names derived from it.
- Return type:
tuple[tuple[N,NodeDefinition[V]],...]
- class Declared[N: Label, V: Place](plan: Plan, given: OrderedMap[V, Any], place_tags: Tags[V] = {}, node_tags: Tags[N] = {})[source]¶
Bases:
Frozen,Generic[N,V]A plan, the values given at its boundary inputs, and the tags written on its places and on its node names. An op edits the plan alone: a value or a tag at a place the plan renames away is left where it was written, and a run takes no value nothing reads.
- given: OrderedMap[V, Any]¶
- property graph: NestingGraph[N, V]¶
- declare(*models: Any)[source]¶
Everything the models declare, each at the node name its position in the tree gives, as a plan, with the values and tags written beside it: declare(d1, d2, {‘opt’: opt}). A declaration held by another keeps only nodes_when_held, a held node nothing.
- Return type:
- loose_at[N](model: Declaration | NodeDefinition, names: DerivedNames[N, Any])[source]¶
The node name a model handed over loose takes, refused where it says none.
- Return type:
N
- tags_of[T: Tagged](declared: Declared, name: Any, kind: type[T])[source]¶
The tags of kind written on name, a place or a node name.
- Return type:
tuple[T,...]