cottax.pytree.consumers.surface

Places and node names written as key paths: the V / N builders, the names derived from one (PytreeDerivedNames, registered), and the locators (chosen as a surface’s locator).

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

class PytreeLocator[source]

Bases: Locator[VarPath, NodePath]

What every pytree locator decides alike: a string where a node is due is a key at the root, as a slot in a mapping names one. What a string means where a place is due is each final’s.

places

alias of VarPath

nodes

alias of NodePath

node(s: str)[source]

A string written where a node is due.

Return type:

NodePath

class Under(root: Var, key: type[GetAttrKey] | type[DictKey])[source]

Bases: PytreeLocator

A place string one key under a root, the key a GetAttrKey or a DictKey.

root: Var
key: type[GetAttrKey] | type[DictKey]
checks: PerLevel[tuple[Callable[[Any], object], ...]] = (<function check_name_key>,)

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

place(s: str)[source]

A string written where a place is due.

Return type:

VarPath

property V: Keys

any path relative to it, in V’s syntax, where a string can say only one name: tfcoil.locator.V.coils[0].j.

Type:

A builder at the root

class InFull[source]

Bases: PytreeLocator

No place strings: every place written in full, a V path or a VarPath.

place(s: str)[source]

A string written where a place is due.

Return type:

VarPath

property V: Keys

the root is the root.

Type:

V itself

Submodules