Skip to content

Commit c781216

Browse files
committed
update scf_cond_unknown to use Flatten
1 parent 0b47339 commit c781216

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

test/analysis/measure_id/test_measure_id.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from bloqade.analysis.measure_id import MeasurementIDAnalysis
66
from bloqade.stim.passes.flatten import Flatten
77
from bloqade.analysis.measure_id.lattice import (
8-
AnyMeasureId,
98
NotMeasureId,
109
MeasureIdBool,
1110
MeasureIdTuple,
@@ -185,14 +184,21 @@ def test(cond: bool):
185184

186185
return ms
187186

188-
InlinePass(test.dialects).fixpoint(test)
187+
# We can use Flatten here because the variable condition for the scf.IfElse
188+
# means it cannot be simplified.
189+
Flatten(test.dialects).fixpoint(test)
189190
frame, _ = MeasurementIDAnalysis(test.dialects).run_analysis(test)
190-
# the result of the analysis on this Scf.IfElse should be two AnyMeasureIds.
191-
# One AnyMeasureId is from resolving the boolean type, which does not change
192-
# during any of the branches. The other is from the fact that broadcast.measure gives
193-
# an AnyMeasureId because it cannot figure out the concrete number of measurements, which has to be
194-
# joined against the MeasureIdBool from the other branch.
195-
assert list(frame.entries.values())[-2:] == [AnyMeasureId(), AnyMeasureId()]
191+
analysis_results = [
192+
val for val in frame.entries.values() if isinstance(val, MeasureIdTuple)
193+
]
194+
# Both branches of the scf.IfElse should be properly traversed and contain the following
195+
# analysis results.
196+
expected_full_register_measurement = MeasureIdTuple(
197+
data=tuple([MeasureIdBool(idx=i) for i in range(1, 6)])
198+
)
199+
expected_else_measurement = MeasureIdTuple(data=(MeasureIdBool(idx=6),))
200+
assert expected_full_register_measurement in analysis_results
201+
assert expected_else_measurement in analysis_results
196202

197203

198204
def test_slice():

0 commit comments

Comments
 (0)