cirq.Circuit.insert

Circuit.insert(index: int, moment_or_operation_tree: Union[cirq.ops.moment.Moment, cirq.ops.raw_types.Operation, Iterable[Any]], strategy: cirq.circuits.insert_strategy.InsertStrategy = cirq.InsertStrategy.EARLIEST) → int[source]
Inserts operations into the circuit.
Operations are inserted into the moment specified by the index and
‘InsertStrategy’.
Moments within the operation tree are inserted intact.
Parameters:
  • index – The index to insert all of the operations at.
  • moment_or_operation_tree – The moment or operation tree to insert.
  • strategy – How to pick/create the moment to put operations into.
Returns:

The insertion index that will place operations just after the operations that were inserted by this method.

Raises:

ValueError – Bad insertion strategy.