DimVar

Contents

DimVar#

class penzai.core.shapecheck.DimVar[source]#

Bases: Mapping

A dimension variable, which will be matched with the shapes in a structure.

In a slight abuse of syntax, DimVar can be unpacked using * or ** to bind the name to a list or dict of variables instead of a single value. In particular, if foo is a DimVar, then *foo expands to a MultiDimVar that will capture more than one name, and **foo expands to a dictionary that maps a MultiDimVar to the singleton placeholder RemainingAxisPlaceholder. It’s also possible to index a DimVar with an integer or string key, for consistency with the output of vars_for_axes and the unpacking constraint solver.

The usual way to create a DimVar is using the var or vars_for_axes functions.

Variables:

name (str | tuple[str, str | int]) – The unique name for this variable. Variable identity is based on this name. May also be a tuple, where the outer name is a name for a collection and the inner name is the named shape of a single axis in that collection.

Methods

__init__(name)

Attributes

name

Inherited Methods

(expand to view inherited methods)

get(k[,d])

items()

keys()

values()