MatchResult

Contents

MatchResult#

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

Bases: Mapping[str, int | tuple[int, …] | dict[Hashable, int]]

The result of a successful shape check.

The bound match variables can be extracted in four ways:

  • Use ordinary dict indexing, e.g. result["foo"]

  • Use attribute access, e.g. result.foo

  • Pass multiple keys like a slice to get multiple results, e.g. result["foo", "bar"] is the same as (result["foo"], result["bar"])

  • Convert to a dictionary using e.g. dict(result)

Variables:

_bindings (dict[str, int | tuple[int, ...] | dict[named_axes.AxisName, int]]) – Resulting bindings from the match.

Methods

__init__(_bindings)

Inherited Methods

(expand to view inherited methods)

get(k[,d])

items()

keys()

values()