KnownDim

Contents

KnownDim#

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

Bases: object

A dimension with a known value, used to bind a name to a value directly.

The usual way to create a KnownDim is by calling vars_for_axes with a dictionary that maps axis names to known sizes. They are also constructed internally by check_structure while solving for variables.

Variables:
  • name (str | tuple[str, str | int]) – The unique name for a variable bound to this dimension. Variable identity is based on this name. Dots in a name have special meaning, referring to sub-variables of a larger 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.

  • size (int) – The size that this variable maps to.

  • from_keypath (str | None) – Optional keypath that indicates where this size was bound.

Methods

__init__(name, size[, from_keypath])

Attributes

from_keypath

name

size