cottax.core.frozen.base module

Frozen, the base every frozen dataclass of the graph layer inherits from: AbstractVar and AbstractClassVar as in equinox, without jax; abstract-or-final enforced for them and for every method; checks accumulated per level rather than overridden.

class AbstractVar[T][source]

Bases: Generic[T]

Annotation only, on a level: fn: AbstractVar[Callable].

class AbstractClassVar[T][source]

Bases: Generic[T]

Annotation only, on a level: fn: AbstractClassVar[Callable]. A class variable

class PerLevel[T][source]

Bases: Generic[T]

Annotation only, on the level that declares it: checks: PerLevel[tuple] = (). A class variable each level binds for itself, read with per_level, which accumulates them root first – so a level adds and never replaces.

unchecked(*skipped: Callable[[Any], object])[source]

Disable Frozen checks for the scope of with: the callables in skipped, matched by identity, or all if skipped is empty.

class Frozen[source]

Bases: ABC

Every subclass is a frozen dataclass whose checks, each level’s added to its ancestors’, run at post-init.

checks: PerLevel[tuple[Callable[[Any], object], ...]] = ()

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

classmethod per_level(name: str, derived_first: bool = False)[source]

Get the attribute name from each level in the MRO, in order from base to implementation, or the reverse. name is one a level declared PerLevel.

Return type:

Iterator[Callable]