as_array_structure

as_array_structure#

penzai.core.shapecheck.as_array_structure(tree: Any) StructureAnnotation[source]#

Abstracts a concrete tree of values into a tree of ArraySpec nodes.

Parameters:

tree – The tree to get an array structure for.

Returns:

A copy of tree where each arraylike or NamedArray subtree is replaced by an ArraySpec, and each other leaf is replaced by ANY.