Skip to content

Commit 763fd6a

Browse files
authored
Don't compare MeasurementResult with int (#300)
1 parent adbb031 commit 763fd6a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/digital/examples/qasm2/repeat_until_success.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def z_phase_gate_postselect(target: qasm2.Qubit, theta: float) -> qasm2.Qubit:
5858
qasm2.cx(ancilla, target)
5959
creg = qasm2.creg(1)
6060
qasm2.measure(target, creg[0])
61-
if creg[0] == 1:
61+
if creg[0]:
6262
qasm2.x(ancilla)
6363
return ancilla
6464

@@ -81,9 +81,9 @@ def z_phase_gate_recursive(target: qasm2.Qubit, theta: float) -> qasm2.Qubit:
8181
qasm2.cx(ancilla, target)
8282
creg = qasm2.creg(1)
8383
qasm2.measure(target, creg[0])
84-
if creg[0] == 0:
84+
if not creg[0]:
8585
return z_phase_gate_recursive(ancilla, 2 * theta)
86-
if creg[0] == 1:
86+
if creg[0]:
8787
qasm2.x(ancilla)
8888
return ancilla
8989

@@ -104,7 +104,7 @@ def z_phase_gate_loop(target: qasm2.Qubit, theta: float, attempts: int):
104104
creg = qasm2.creg(1) # Implicitly initialized to 0, thanks qasm...
105105
for ctr in range(attempts):
106106
ancilla = prep_resource_state(theta * (2**ctr))
107-
if creg[0] == 0:
107+
if not creg[0]:
108108
qasm2.cx(ancilla, target)
109109
qasm2.measure(target, creg[0])
110110
target = ancilla

0 commit comments

Comments
 (0)