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, iffoo
is aDimVar
, then*foo
expands to aMultiDimVar
that will capture more than one name, and**foo
expands to a dictionary that maps aMultiDimVar
to the singleton placeholderRemainingAxisPlaceholder
. It’s also possible to index aDimVar
with an integer or string key, for consistency with the output ofvars_for_axes
and the unpacking constraint solver.The usual way to create a DimVar is using the
var
orvars_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
()