cirq.flatten_to_ops_or_moments

cirq.flatten_to_ops_or_moments(root: Union[cirq.ops.raw_types.Operation, cirq.ops.op_tree.OpTree]) → Iterator[Union[cirq.ops.raw_types.Operation, cirq.ops.moment.Moment]][source]

Performs an in-order iteration OP_TREE, yielding ops and moments.

Parameters

root – The operation or tree of operations to iterate.

Yields

Operations or moments from the tree.

Raises

TypeError – root isn’t a valid OP_TREE.