Skip to content

Commit 64c1b99

Browse files
johnzl-777david-pl
authored andcommitted
relax scf tests so they don't sporadically fail (#514)
1 parent 0919688 commit 64c1b99

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

test/analysis/measure_id/test_measure_id.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from bloqade.squin import op, qubit, kernel
55
from bloqade.analysis.measure_id import MeasurementIDAnalysis
66
from bloqade.analysis.measure_id.lattice import (
7-
NotMeasureId,
87
MeasureIdBool,
98
MeasureIdTuple,
109
InvalidMeasureId,
@@ -111,10 +110,15 @@ def test():
111110
HintConst(dialects=test.dialects).unsafe_run(test)
112111
frame, _ = MeasurementIDAnalysis(test.dialects).run_analysis(test)
113112

114-
assert [frame.entries[result] for result in results_at(test, 0, 7)] == [
115-
NotMeasureId(),
116-
MeasureIdTuple((MeasureIdBool(idx=1),)),
113+
# MeasureIdTuple(data=MeasureIdBool(idx=1),) should occur twice:
114+
# First from the measurement in the true branch, then
115+
# the result of the scf.IfElse itself
116+
analysis_results = [
117+
val
118+
for val in frame.entries.values()
119+
if val == MeasureIdTuple(data=(MeasureIdBool(idx=1),))
117120
]
121+
assert len(analysis_results) == 2
118122

119123

120124
def test_scf_cond_false():
@@ -136,10 +140,13 @@ def test():
136140
HintConst(dialects=test.dialects).unsafe_run(test)
137141
frame, _ = MeasurementIDAnalysis(test.dialects).run_analysis(test)
138142

139-
assert [frame.entries[result] for result in results_at(test, 0, 7)] == [
140-
NotMeasureId(),
141-
MeasureIdBool(idx=1),
143+
# MeasureIdBool(idx=1) should occur twice:
144+
# First from the measurement in the false branch, then
145+
# the result of the scf.IfElse itself
146+
analysis_results = [
147+
val for val in frame.entries.values() if val == MeasureIdBool(idx=1)
142148
]
149+
assert len(analysis_results) == 2
143150

144151

145152
def test_slice():

0 commit comments

Comments
 (0)