cottax.core.realisation.implemented module¶
Implemented nodes: both a function and a driver.
Implementation is an arbitrary object: it can be a function, a description of a repo or something else entirely.
- check_implemented_once(implemented: Implemented)[source]¶
One implementation on a node: a second would replace the first in silence.
- Return type:
Iterator[Violation]
- class Implemented[V: Place][source]¶
Bases:
NodeDefinition[V],Generic[V]A node with what runs it: a callable, or a description of one (location etc.).
- node: AbstractVar[NodeDefinition[V]]¶
a final’s level narrows it.
- Type:
The node run
- implementation: AbstractVar[object]¶
What runs it.
- checks: PerLevel[tuple[Callable[[Any], object], ...]] = (<function check_implemented_once>,)¶
Callable [self] -> iterable of violations, which are raised at construction unless skipped (see unchecked).
- property reads: 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
- property owns: 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
- relabel(renaming: Renaming[V])[source]¶
The same definition with its places renamed.
- Return type:
Implemented[V]
- check_a_function(implemented: ImplementedFunction)[source]¶
A body goes on a function: on anything else it would silently turn it into one.
- Return type:
Iterator[Violation]
- class ImplementedFunction[V: Place](node: FunctionalNode[V], implementation: object)[source]¶
Bases:
Implemented[V],FunctionalNode[V],Generic[V]A function with its body.
- node: FunctionalNode[V]¶
a final’s level narrows it.
- Type:
The node run
- implementation: object¶
What runs it.
- check_a_contract(implemented: ImplementedDriven)[source]¶
What runs a driver goes on a driven node: a bare condition node has no contract for it to answer.
- Return type:
Iterator[Violation]
- class ImplementedDriven[V: Place](node: DrivenNode[V], implementation: object)[source]¶
Bases:
Implemented[V],DrivenNode[V],Generic[V]A driven node with what runs its driver.
- node: DrivenNode[V]¶
a final’s level narrows it.
- Type:
The node run
- implementation: object¶
What runs it.
- checks: PerLevel[tuple[Callable[[Any], object], ...]] = (<function check_a_contract>,)¶
Callable [self] -> iterable of violations, which are raised at construction unless skipped (see unchecked).
- property unknowns: 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
- property conditions: 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
- property condition: ConditionalNode[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
- property contract: DriverContract[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
- property data: tuple[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
- property reports: tuple[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
- implemented_as(node: NodeDefinition)[source]¶
The final implementing node, by its level; None for a level nothing implements. A wrapper joins its level, so a second implementation reaches ImplementedTwice.
- Return type:
type[Implemented] |None
- check_implementable(op: Implement, graph: NestingGraph)[source]¶
Each node it makes is well formed – asked here, so a refusal is data before the graph is touched.
- Return type:
Iterator[Violation]
- class Implement[N: Label, V: Place](implementations: OrderedMap[N, object])[source]¶
Bases:
Redefine[N,V],Generic[N,V]Supply what runs some nodes – a function’s body, a driven node’s driver implementation – in one op, since choosing a backend is one decision. Their places are the nodes’ own and are handed straight on.
- implementations: OrderedMap[N, object]¶
- checks: PerLevel[tuple[Callable[[Any], object], ...]] = (<function check_implements_something>,)¶
Callable [self] -> iterable of violations, which are raised at construction unless skipped (see unchecked).
- checks_graph: PerLevel[tuple[Callable, ...]] = (<function check_implementable>,)¶
(op, graph) -> Iterator[Violation], collected by refusals and raised by apply.
- Type:
What the op needs of the graph before it can compute anything
- redefined(graph: NestingGraph[N, V])[source]¶
The new definition for each node this touches. Names not here are untouched.
- Return type:
Mapping[N,NodeDefinition[V]]
- check_unimplements_implemented(op: Unimplement, graph: NestingGraph)[source]¶
There is an implementation to drop, on each.
- Return type:
Iterator[Violation]
- check_unimplements_something(op: Unimplement)[source]¶
Some node, none twice.
- Return type:
Iterator[Violation]
- class Unimplement[N: Label, V: Place](nodes: tuple[N, ...])[source]¶
Bases:
Redefine[N,V],Generic[N,V]The inverse of Implement: the implementations dropped, the nodes kept.
- nodes: tuple[N, ...]¶
- checks: PerLevel[tuple[Callable[[Any], object], ...]] = (<function check_unimplements_something>,)¶
Callable [self] -> iterable of violations, which are raised at construction unless skipped (see unchecked).
- checks_graph: PerLevel[tuple[Callable, ...]] = (<function check_unimplements_implemented>,)¶
(op, graph) -> Iterator[Violation], collected by refusals and raised by apply.
- Type:
What the op needs of the graph before it can compute anything
- redefined(graph: NestingGraph[N, V])[source]¶
The new definition for each node this touches. Names not here are untouched.
- Return type:
Mapping[N,NodeDefinition[V]]
- class ImplementDrivers[N: Label, V: Place](implementations: OrderedMap[type[DriverContract], object])[source]¶
Bases:
ComposedOp[N,V],Generic[N,V]What runs every driven node not yet implemented, chosen by its driver’s type: the entry of the most specific contract along its ancestry, whatever order the map is written in. A rule, so on a changed model it chooses again; a node no entry covers is left for the proof to refuse, and a graph with none to implement is refused by Implement.
- implementations: OrderedMap[type[DriverContract], object]¶
- class ImplementedTwice(node: object)[source]¶
Bases:
Violation- node: object¶
- template: AbstractClassVar[str] = '{node!r} already has an implementation -- replacing one with another silently is not a rewrite; `Unimplement` it first'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class NotAFunction(node: object, kind: str)[source]¶
Bases:
Violation- node: object¶
- kind: str¶
- template: AbstractClassVar[str] = '{node!r} is a {kind}, which is answered rather than run -- only a function takes a body'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class NotImplementable(node: object, kind: str)[source]¶
Bases:
Violation- node: object¶
- kind: str¶
- template: AbstractClassVar[str] = 'nothing implements a {kind}, which is what {node!r} is -- only a function or a driven node is implemented'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class NothingImplemented[source]¶
Bases:
Violation- template: AbstractClassVar[str] = 'names no node, so there is nothing to implement or take off'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class NodeNamedTwice(nodes: tuple)[source]¶
Bases:
Violation- nodes: tuple¶
- template: AbstractClassVar[str] = 'unimplement(): {nodes!r} named twice'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class NotImplementedYet(node: object, kind: str)[source]¶
Bases:
Violation- node: object¶
- kind: str¶
- template: AbstractClassVar[str] = '{node!r} is a {kind} and carries no implementation, so there is nothing to take off'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class NoContract(node: object, kind: str)[source]¶
Bases:
Violation- node: object¶
- kind: str¶
- template: AbstractClassVar[str] = '{node!r} is a {kind} with no driver, so there is no contract for an implementation to answer -- `Assign` one first'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class DeterminedWhileImplemented(unknowns: tuple, asked: tuple)[source]¶
Bases:
Violation- unknowns: tuple¶
- asked: tuple¶
- template: AbstractClassVar[str] = 'this node is implemented over {unknowns!r}, so it cannot be made to determine {asked!r} -- `Unimplement` it first'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class UndrivenWhileImplemented(driver: str)[source]¶
Bases:
Violation- driver: str¶
- template: AbstractClassVar[str] = 'this {driver} is implemented, and the implementation runs it, so the driver cannot be taken off under it -- `Unimplement` it first'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording