cottax.core.realisation

What runs a node, at any level, a driven one included. Takes core and driven/: a driven node’s wrapper joins its level. Generic in the place, and no backend’s.

Dependency:

driven/ (DrivenNode, the level ImplementedDriven joins)

|| /

implemented (Implemented, the level; ImplementedFunction /

|| ImplementedDriven, picked by the node’s level in || implemented_as; Implement / Unimplement, / ImplementDrivers)

proof (RealisedGraph over driven.DrivenGraph: every node implemented)

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]

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.

checks: PerLevel[tuple[Callable[[Any], object], ...]] = (<function check_a_function>,)

Callable [self] -> iterable of violations, which are raised at construction unless skipped (see unchecked).

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

determined(unknowns: tuple[V, ...])[source]

Refused: take off the outer layer first.

Return type:

ImplementedDriven[V]

undriven()[source]

Refused: the implementation runs this driver, so it comes off first.

Return type:

ConditionalNode[V]

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

is_implemented(d: object)[source]
Return type:

bool

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]]

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]
composed(graph: NestingGraph[N, V])[source]

The ops this one is. Takes a graph, so an expansion may depend on what it meets.

Return type:

Sequence[GraphOp[N, V]]

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 RealisedGraph[N: Label, V: Place](graph: NestingGraph[N, V])[source]

Bases: DrivenGraph[N, V], Generic[N, V]

A driven graph with what runs every node: what a backend’s proof strengthens.

checks_node: PerLevel[tuple[Callable[[N, NodeDefinition[V]], Iterator[Violation]], ...]] = (<function check_implemented>,)

the one thing a level below adds.

Type:

(name, node) -> violations

Submodules