quick.circuit.Circuit.__eq__ inconsistency depending on operation order
Description
The __eq__ method for quick.circuit.Circuit uses the circuit_log attribute to assert equality. This means the order determines equality as well. Whilst order is important, certain operations can be reordered as they do not alter the circuit definition itself. For instance:
qc = QiskitCircuit(3)
qc.X(0)
qc.X(1)
qc_eq = QiskitCircuit(3)
qc.X(1)
qc.X(0)
won't be equal, even though they are in fact equal.
Tips
- Instead of operation order alone, use a QIR for proper assessment. This could be done using the DAG representation, however, one must note that the DAG does NOT check for equal definition if the gates are of the same name. This will cause incorrect functionality should users accidentally or intentionally introduce gates with different definitions but identical name to an existing gate.
quick.circuit.Circuit.__eq__inconsistency depending on operation orderDescription
The
__eq__method forquick.circuit.Circuituses thecircuit_logattribute to assert equality. This means the order determines equality as well. Whilst order is important, certain operations can be reordered as they do not alter the circuit definition itself. For instance:won't be equal, even though they are in fact equal.
Tips