cottax.core.maths.definition module¶
Node definition and its checks
- check_owns_are_separate(d: NodeDefinition)[source]¶
Check that no two of this node’s owns overlap: none of them are comparable.
o || m ∀ o,m ∊ O_n, o ≠ m
- Return type:
Iterator[Violation]
- check_reads_outside_owns(d: NodeDefinition)[source]¶
Check whether the reads and owns are not comparable.
o || i ∀ o ∊ O_n, i ∊ I_n
- Return type:
Iterator[Violation]
- type Renaming[V: Place] = Mapping¶
Old place -> new, per node. Keyed by the place, so fn(x, x) renames both reads.
- class NodeDefinition[V: Place][source]¶
Bases:
Frozen,Generic[V]Node definition: has owns and reads and a way to relabel them. Checked at construction by the two rules above; each level adds its own.
- owns: AbstractVar[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
- reads: AbstractVar[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
- checks: PerLevel[tuple[Callable[[Any], object], ...]] = (<function check_owns_are_separate>, <function check_reads_outside_owns>)¶
Callable [self] -> iterable of violations, which are raised at construction unless skipped (see unchecked).
- relabelled[V: Place](places: Iterable[V], renaming: Renaming[V])[source]¶
A field of places renamed. What a relabel implementation is made of.
- Return type:
tuple[V,...]
- class OwnsTwice(place: Place, other: Place)[source]¶
Bases:
Violation- template: AbstractClassVar[str] = 'duplicate output name {place!r}'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class OwnsNested(place: Place, other: Place)[source]¶
Bases:
Violation- template: AbstractClassVar[str] = 'owns {place!r} and {other!r}, one inside the other -- two outputs written to one storage'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class ReadsOwn(place: Place)[source]¶
Bases:
Violation- template: AbstractClassVar[str] = 'reads {place!r}, which it also owns. Reading the name a node produces back makes it mean the value assumed and the value produced at once -- `Cut` it and read the copy'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording
- class ReadInsideOwn(place: Place, own: Place)[source]¶
Bases:
Violation- template: AbstractClassVar[str] = 'reads {place!r}, which lies inside {own!r}, which it owns -- reads are matched by equality, so this read would silently miss its own output'¶
e.g. ‘output {place!r} is owned by both {other!r} and {node!r}’
- Type:
Wording