qml.pytrees.PyTreeStructure

class PyTreeStructure(type_=None, metadata=(), children=<factory>)[source]

Bases: object

A pytree data structure, holding the type, metadata, and child pytree structures.

>>> op = qml.adjoint(qml.RX(0.1, 0))
>>> data, structure = qml.pytrees.flatten(op)
>>> structure
PyTree(AdjointOperation, (), [PyTree(RX, (Wires([0]), ()), [Leaf])])

A leaf is defined as just a PyTreeStructure with type_=None.

is_leaf

Whether or not the structure is a leaf.

metadata

Any metadata needed to reproduce the original object.

type_

The type corresponding to the node.

is_leaf

Whether or not the structure is a leaf.

metadata: Any = ()

Any metadata needed to reproduce the original object.

type_: Optional[type] = None

The type corresponding to the node. If None, then the structure is a leaf.