Circuit.remove

Circuit.remove(op)[source]

Removes the first occurrence of op in the circuit.

Parameters:

op (Operation | Gate) – The Operation or Gate to remove.

Raises:
  • ValueError – If the op doesn’t exist in the circuit.

  • ValueError – If op could not have been placed on the circuit due to either an invalid location or gate radix mismatch.

Examples

>>> from bqskit.ir.gates import HGate
>>> circ = Circuit(1)
>>> op = Operation(HGate(), [0])
>>> circ.append(op)
>>> circ.num_operations
1
>>> circ.remove(op)
>>> circ.num_operations
0

See also

remove_all()