cirq.ops.op_tree.OpTree

The recursive type consumed by circuit builder methods.

An OpTree is a type protocol, satisfied by anything that can be recursively flattened into Operations. We also define the Union type OP_TREE which can be an OpTree or just a single Operation.

For example:

  • An Operation is an OP_TREE all by itself.
  • A list of operations is an OP_TREE.
  • A list of tuples of operations is an OP_TREE.
  • A list with a mix of operations and lists of operations is an OP_TREE.
  • A generator yielding operations is an OP_TREE.

OP_TREE = Union[Operation, Iterable['OP_TREE']]

See: https://github.com/python/mypy/issues/731

Methods

__iter__

View source