@@ -26,6 +26,85 @@ def test_solve_flow_measurements():
2626 ]) == [[0 ], [], [0 ]]
2727
2828
29+ def test_solve_flow_generators_measurements_multi_target ():
30+ assert stim .Circuit ("""
31+ M 1 2
32+ """ ).flow_generators () == [
33+ stim .Flow ("1 -> __Z xor rec[1]" ),
34+ stim .Flow ("1 -> _Z_ xor rec[0]" ),
35+ stim .Flow ("__Z -> rec[1]" ),
36+ stim .Flow ("_Z_ -> rec[0]" ),
37+ stim .Flow ("X__ -> X__" ),
38+ stim .Flow ("Z__ -> Z__" ),
39+ ]
40+
41+ assert stim .Circuit ("""
42+ MX 1 2
43+ """ ).flow_generators () == [
44+ stim .Flow ("1 -> __X xor rec[1]" ),
45+ stim .Flow ("1 -> _X_ xor rec[0]" ),
46+ stim .Flow ("__X -> rec[1]" ),
47+ stim .Flow ("_X_ -> rec[0]" ),
48+ stim .Flow ("X__ -> X__" ),
49+ stim .Flow ("Z__ -> Z__" ),
50+ ]
51+
52+ assert stim .Circuit ("""
53+ MYY 1 2 3 4
54+ """ ).flow_generators () == [
55+ stim .Flow ("1 -> ___YY xor rec[1]" ),
56+ stim .Flow ("1 -> _YY__ xor rec[0]" ),
57+ stim .Flow ("____Y -> ____Y" ),
58+ stim .Flow ("___XZ -> ___ZX xor rec[1]" ),
59+ stim .Flow ("___ZZ -> ___ZZ" ),
60+ stim .Flow ("__Y__ -> __Y__" ),
61+ stim .Flow ("_XZ__ -> _ZX__ xor rec[0]" ),
62+ stim .Flow ("_ZZ__ -> _ZZ__" ),
63+ stim .Flow ("X____ -> X____" ),
64+ stim .Flow ("Z____ -> Z____" ),
65+ ]
66+ assert stim .Circuit ("""
67+ MPP Y1*Y2 Y3*Y4
68+ """ ).flow_generators () == [
69+ stim .Flow ("1 -> ___YY xor rec[1]" ),
70+ stim .Flow ("1 -> _YY__ xor rec[0]" ),
71+ stim .Flow ("____Y -> ____Y" ),
72+ stim .Flow ("___XZ -> ___ZX xor rec[1]" ),
73+ stim .Flow ("___ZZ -> ___ZZ" ),
74+ stim .Flow ("__Y__ -> __Y__" ),
75+ stim .Flow ("_XZ__ -> _ZX__ xor rec[0]" ),
76+ stim .Flow ("_ZZ__ -> _ZZ__" ),
77+ stim .Flow ("X____ -> X____" ),
78+ stim .Flow ("Z____ -> Z____" ),
79+ ]
80+
81+
82+ def test_solve_flow_measurements_multi_target ():
83+ assert stim .Circuit ("""
84+ M 1 2
85+ """ ).solve_flow_measurements ([
86+ stim .Flow ("Z1 -> 1" ),
87+ ]) == [[0 ]]
88+
89+ assert stim .Circuit ("""
90+ MX 1 2
91+ """ ).solve_flow_measurements ([
92+ stim .Flow ("X1 -> 1" ),
93+ ]) == [[0 ]]
94+
95+ assert stim .Circuit ("""
96+ MYY 1 2 3 4
97+ """ ).solve_flow_measurements ([
98+ stim .Flow ("Y1*Y2 -> 1" ),
99+ ]) == [[0 ]]
100+
101+ assert stim .Circuit ("""
102+ MPP Y1*Y2 Y3*Y4
103+ """ ).solve_flow_measurements ([
104+ stim .Flow ("Y1*Y2 -> 1" ),
105+ ]) == [[0 ]]
106+
107+
29108def test_solve_flow_measurements_fewer_measurements_heuristic ():
30109 assert stim .Circuit ("""
31110 MPP Z0*Z1*Z2*Z3*Z4*Z5*Z6*Z7*Z8
0 commit comments