qml.pytrees.unflatten

unflatten(data, structure)[source]

Bind data to a structure to reconstruct a pytree object.

Parameters
  • data (Iterable) – iterable of numbers and numeric arrays

  • structure (Structure, Leaf) – The pytree structure object

Returns

A repacked pytree.

See also

flatten()

Example

>>> op = qml.adjoint(qml.Rot(1.2, 2.3, 3.4, wires=0))
>>> data, structure = flatten(op)
>>> unflatten([-2, -3, -4], structure)
Adjoint(Rot(-2, -3, -4, wires=[0]))