You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Python file example_qiskit_conditional.py, the c_if gates are used without preceding measurements. This could lead to ambiguities as the c_if gates are conditional and depend on the state of the classical registers.
How can we reproduce the issue?
Run the following code in the Python file:
q=QuantumRegister(3, "q")
c0=ClassicalRegister(1, "c0")
c1=ClassicalRegister(1, "c1")
c2=ClassicalRegister(1, "c2")
qc=QuantumCircuit(q, c0, c1, c2, name="conditional")
qc.h(q[0])
qc.h(q[1]).c_if(c0, 0) # h-gate on q[1] is executedqc.h(q[2]).c_if(c1, 1) # h-gate on q[2] is not executedqc.measure(q[0], c0)
qc.measure(q[1], c1)
qc.measure(q[2], c2)
What should happen?
I would have expected either to have preceding measurements, such as:
q=QuantumRegister(3, "q")
c0=ClassicalRegister(1, "c0")
c1=ClassicalRegister(1, "c1")
c2=ClassicalRegister(1, "c2")
qc=QuantumCircuit(q, c0, c1, c2, name="conditional")
qc.h(q[0])
qc.measure(q[0], c0)
qc.h(q[1]).c_if(c0, 0) # h-gate on q[1] is executedqc.measure(q[1], c1)
qc.h(q[2]).c_if(c1, 1) # h-gate on q[2] is not executedqc.measure(q[0], c0)
qc.measure(q[1], c1)
qc.measure(q[2], c2)
Environment
What is happening?
In the Python file example_qiskit_conditional.py, the
c_if
gates are used without preceding measurements. This could lead to ambiguities as thec_if
gates are conditional and depend on the state of the classical registers.How can we reproduce the issue?
Run the following code in the Python file:
What should happen?
I would have expected either to have preceding measurements, such as:
Or to have the
c_if
gates removed, such as:To avoid ambiguity.
Thanks in advance, I wish you a happy and productive day.
The text was updated successfully, but these errors were encountered: