cottax.consumers.surface.interface_types module

type Named[P] = str | P

A place as written: a name, or a path.

class Step[source]

Bases: Frozen

One step from a container of models to what it holds: a name its place gives the node (DerivedNames.node_in_tree).

class Field(name: str)[source]

Bases: Step

A dataclass’s public field, or a named tuple’s.

name: str
class Key(key: Any)[source]

Bases: Step

A mapping’s key; a loose wrapper’s own name.

key: Any
class Index(index: int)[source]

Bases: Step

A tuple’s or a list’s index.

index: int
class Surface[N: Label, V: Place](locator: Locator[V, N])[source]

Bases: Frozen, Generic[N, V]

What a model is written through: locator says what a bare string means, and what else is written means what its Written answer says. A part is a level under it adding methods; a surface a study uses joins parts, a class. A method’s parameter annotated Place, Label or a tuple of either (alone, | None, varargs, or in a Mapping) is read through the surface before the method runs: a caller writes it any way the surface reads, and the method is handed it exact.

locator: Locator[V, N]
located(locator: Locator[V, N])[source]

The same surface, strings meaning what locator says.

Return type:

Self

place(written: Any, *, role: str = 'what is written')[source]

A place: a string, as the locator says, an exact place, or what it stands for (Written), if one place: a V path, a wrapper’s one output.

Return type:

V

places(written: Any, *, role: str = 'what is written')[source]

Places: one written alone, or several; what stands for places, all of them.

Return type:

tuple[V, ...]

node(written: Any, *, role: str = 'what is written')[source]

A node name: a string, as the locator says, an exact name, or the name it takes (Written): an N path, a wrapper’s function’s name.

Return type:

N

nodes(written: Any, *, role: str = 'what is written')[source]

Node names: one written alone, or several.

Return type:

tuple[N, ...]

property derived: DerivedNames[N, V]

The names derived from the class of place the locator locates.

class Purpose(mint: Mint)[source]

Bases: Frozen

A purpose as a study writes it: called on a name as written, the Derived name.

mint: Mint
beside(written: Any, *names: str)[source]

The place for this purpose names deeper than the place written.

Return type:

Derived

class Derived(mint: Mint, written: Any, beside: tuple[str, ...])[source]

Bases: Frozen

The name mint derives from one as written, read where the surface reads it and never stored: cx.copy(‘y’), cx.solve(‘f’), cx.given.beside(‘y’, ‘k’) (beside the names one deeper first, a place only).

mint: Mint
written: Any
beside: tuple[str, ...]
class Given[source]

Bases: Mint

A read written as a value, beside the first output: ^given.<output>.<parameter>.

class Start[source]

Bases: Mint

Where each unknown starts: ^start.u.

class Steps[source]

Bases: Mint

How many iterations a solve took: ^steps.<the problem>.

class RolePlaces(entries: OrderedMap[type[Role], PlaceToPlace])[source]

Bases: Frozen

Where a driver’s data and reports go, a rule per role (entries), found along the role’s ancestry, the most specific first: a PerUnknown role’s applied to each unknown, a PerProblem one’s to the problem’s name read as a place. A role with no entry is refused: nothing is named after a role unless a rule says so. a | b joins two, b’s winning.

entries: OrderedMap[type[Role], PlaceToPlace]
rule(role: type[Role])[source]

The rule for role: its own entry, else its nearest ancestor’s.

Return type:

PlaceToPlace

core_role_places = RolePlaces(entries={<class 'cottax.core.driven.roles.Start'>: ^start, <class 'cottax.core.driven.roles.Steps'>: ^steps})

a start at ^start.u, the steps at ^steps.<problem>.

Type:

Core’s roles, each at its purpose