DimVar#
- class penzai.core.shapecheck.DimVar[source]#
Bases:
MappingA dimension variable, which will be matched with the shapes in a structure.
In a slight abuse of syntax,
DimVarcan be unpacked using*or**to bind the name to a list or dict of variables instead of a single value. In particular, iffoois aDimVar, then*fooexpands to aMultiDimVarthat will capture more than one name, and**fooexpands to a dictionary that maps aMultiDimVarto the singleton placeholderRemainingAxisPlaceholder. It’s also possible to index aDimVarwith an integer or string key, for consistency with the output ofvars_for_axesand the unpacking constraint solver.The usual way to create a DimVar is using the
varorvars_for_axesfunctions.- 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
nameInherited Methods
(expand to view inherited methods)
get(k[,d])items()keys()values()