Circuit.insert
- Circuit.insert(cycle_index, op)[source]
Insert op in the circuit at the specified cycle.
After this, if cycle was in range, you can expect: all([self[cycle_index, idx] == op for idx in op.location])
Unless cycle_index was out-of-bounds, in which case, it will be appended ASAP rather than inserted.
- Parameters:
cycle_index (
int
) – The cycle to insert the operation.op (
Operation
) – The operation to insert.
- Raises:
ValueError – If op cannot be placed on the circuit due to either an invalid location or gate radix mismatch.
Examples
>>> from bqskit.ir.gates import HGate, XGate >>> circ = Circuit(1) >>> opX = Operation(XGate(), [0]) >>> opH = Operation(HGate(), [0]) >>> circ.append(opX) >>> circ.insert(0, opH) >>> circ.point(opH).cycle 0
Notes
Clamps cycle to be in range.