cottax.core.driven.ops module

The edits putting a driver on and taking it off.

check_drivable(op: Assign, graph: NestingGraph)[source]

An algorithm goes on a condition node without one, and the node it makes is well formed – asked here, so a refusal is data before the graph is touched. The kind is asked for Implement’s reason: the wrapper would otherwise wrap the wrong level. A second driver is asked first, since its reports would otherwise read as owned twice.

Return type:

Iterator[Violation]

class Assign[N: Label, V: Place](problem: N, contract: DriverContract[V], data: tuple[tuple[V, ...], ...], reports: tuple[tuple[V, ...], ...])[source]

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

Attach a driver to a condition node, and say where each of its roles sits: the algorithm choice and its places, recorded in the plan and carried by the node. Where a place sits is a decision, so the op records it: a surface supplies the obvious ones.

problem: N
contract: DriverContract[V]
data: tuple[tuple[V, ...], ...]
reports: tuple[tuple[V, ...], ...]
checks_graph: PerLevel[tuple[Callable, ...]] = (<function check_drivable>,)

(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_assignable(op: AssignByRule, graph: NestingGraph)[source]

A condition node to read the unknowns of, before the places are made from them.

Return type:

Iterator[Violation]

class AssignByRule[N: Label, V: Place](problem: N, contract: DriverContract[V], places: Callable[..., tuple[tuple[tuple[V, ...], ...], tuple[tuple[V, ...], ...]]])[source]

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

Assign at the places places(problem, unknowns, contract) gives, the problem’s unknowns read when it is applied: the rule is recorded, so a changed model has its places derived again.

problem: N
contract: DriverContract[V]
places: Callable[..., tuple[tuple[tuple[V, ...], ...], tuple[tuple[V, ...], ...]]]
checks_graph: PerLevel[tuple[Callable, ...]] = (<function check_assignable>,)

(op, graph) -> Iterator[Violation], collected by refusals and raised by apply.

Type:

What the op needs of the graph before it can compute anything

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:

tuple[Assign[N, V]]

check_undrives_a_driven_node(op: Undrive, graph: NestingGraph)[source]

There is an algorithm to drop.

Return type:

Iterator[Violation]

class Undrive[N: Label, V: Place](problem: N)[source]

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

The inverse of Assign: the condition node alone again, and the driver’s places gone with it – undriven, asked of the node, so a wrapper refuses for itself.

problem: N
checks_graph: PerLevel[tuple[Callable, ...]] = (<function check_undrives_a_driven_node>,)

(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 NotAConditionalNode(problem: object, kind: str)[source]

Bases: Violation

problem: object
kind: str
template: AbstractClassVar[str] = '{problem!r} is a {kind}, not a condition node, so there is nothing for a driver to answer'

e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’

Type:

Wording

class NotDriven(problem: object, kind: str)[source]

Bases: Violation

problem: object
kind: str
template: AbstractClassVar[str] = '{problem!r} is a {kind} and carries no driver, so there is nothing to undrive'

e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’

Type:

Wording