cottax.pytree.consumers.surface.builders module

Writing a place using V or a node using N:

V.plasma.ip[0] = GetAttrKey(‘plasma’), GetAttrKey(‘ip’), SequenceKey(0)

class Keys(into: type[Path], keys: tuple[KeyEntry, ...] = ())[source]

Bases: object

Key Path builder: V or N followed by attribute and index access.

WARNING: a [0] always is a SequenceKey (not a DictKey). Use [DictKey(0)] instead.

Refused: a private or dunder name, which keeps copy, pickle and IPython’s probes from becoming keys.

entry_of(key: Any)[source]

The segment an index writes: a key of a registered key kind (key_kind) as it is, an int a SequenceKey, any other key a DictKey. An index that reads as a number or a slice is refused, and so is a minted segment, which only a mint writes.

Return type:

KeyEntry

V = V

The root of every place.

N = N

The root of every node name.

path_of[P: Path](x: Union[Keys, P], into: type[P])[source]

x as a into: a builder in that namespace, or a path already one. A root names nothing, and a builder of the other namespace is refused.

Return type:

P

type Var = Keys | VarPath
type Node = Keys | NodePath
place_of(x: Var)[source]
Return type:

VarPath

node_of(x: str | Node)[source]

A node name: an N path or a NodePath, or a string, a DictKey at the root, as a slot in a mapping is.

Return type:

NodePath

keys_of(x: Var)[source]

The keys of a place, or of a builder, the root included: what a scope extends.

Return type:

tuple[KeyEntry, ...]