cirq.Circuit.insert

Circuit.insert(index: int, moment_or_operation_tree: Union[cirq.circuits.moment.Moment, cirq.ops.raw_types.Operation, Iterable[Any]], strategy: cirq.circuits.insert_strategy.InsertStrategy = cirq.InsertStrategy.NEW_THEN_INLINE) → int[source]
Inserts a moment or operations into the circuit.
Moments are inserted at the specified index.
Operations are inserted into the moment specified by the index and
‘InsertStrategy’.
Parameters:
  • index – The index to insert all of the operations at.
  • moment_or_operation_tree – An operation or tree of operations.
  • 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.