cottax.core.maths.places module¶
A place: a word over segments, and the prefix order on words.
- type Label = Hashable¶
Where a node is bound: a key, and nothing more.
- class Place(segments: Iterable[Any])[source]¶
Bases:
ProtocolPlace composed over segments of a path (i.e. paths in a nested tree)
- property segments: tuple[Any, ...]¶
The word itself, in order from the root. Finite and hashable.
- type PlaceToPlace[P: Place] = Callable[[P], P]¶
A function on places: what an op that derives a name is handed.
- prefixes[P: Place](place: P)[source]¶
{q : q ⊏ place}, root first. Set of all prefixes. For e.g. .x.y.z yields the root, .x, .x.y.
- Return type:
Iterator[P]
- comparables_in[P: Place](place: P, among: Collection[P], below: Set[P] | None = None)[source]¶
Every place in among comparable to place: itself, its prefixes root first, then its extensions in the order of among. below is {q : q ⊏ x, x ∊ among} when a caller keeps it, so a place with no extension costs no scan of among.
- Return type:
Iterator[P]
- strictly_below[P: Place](among: Iterable[P])[source]¶
{q : q ⊏ x, x ∊ among}: every place with an extension in among.
- Return type:
set[P]
- overlaps[P: Place](places: Iterable[P], others: Collection[P], below: Set[P] | None = None)[source]¶
Overlaps between the two places. below is strictly_below(others) when a caller keeps it (a graph caches its owners’ and readers’).
- Return type:
Iterator[tuple[P,P]]
- self_overlaps[P: Place](places: Iterable[P])[source]¶
Every comparable pair among places, each once, as (later, earlier) in the order given – a duplicate is a pair, a place with itself is not. Empty exactly when the places form an antichain. overlaps of each place with those already seen.
- Return type:
Iterator[tuple[P,P]]