Circuit.append

Circuit.append(op)[source]

Append op to the end of the circuit and return its cycle index.

Parameters:

op (Operation) – The operation to append.

Returns:

The cycle index of the appended operation.

Return type:

int

Raises:

ValueError – If op cannot be placed on the circuit due to either an invalid location or gate radix mismatch.

Notes

Due to the circuit being represented as a matrix, circuit.append(op) does not imply op is last in simulation order but it implies op is in the last cycle of circuit.

Examples

>>> from bqskit.ir.gates import HGate
>>> circ = Circuit(1)
>>> op = Operation(HGate(), [0])
>>> circ.append(op) # Appends a Hadamard gate to qudit 0.