14
14
# See the License for the specific language governing permissions and
15
15
# limitations under the License.
16
16
17
+ from fractions import Fraction
17
18
from typing import Dict , Set , Tuple , Optional
18
19
19
20
from .extract import bi_adj
@@ -76,7 +77,8 @@ def gflow(
76
77
vertices : Set [VT ] = set (v for v in g .vertices () if vertex_is_zx (ty [v ]))
77
78
pattern_inputs : Set [VT ] = set ()
78
79
pattern_outputs : Set [VT ] = set ()
79
- paulis : Set [VT ] = set ()
80
+ pauli_x : Set [VT ] = set ()
81
+ pauli_y : Set [VT ] = set ()
80
82
81
83
for inp in g .inputs ():
82
84
pattern_inputs |= set (n for n in g .neighbors (inp ) if vertex_is_zx (ty [n ]))
@@ -87,7 +89,8 @@ def gflow(
87
89
pattern_inputs , pattern_outputs = pattern_outputs , pattern_inputs
88
90
89
91
if pauli :
90
- paulis = set (v for v in vertices .difference (pattern_inputs ) if g .phase (v ) in (0 ,1 ))
92
+ pauli_x = set (v for v in vertices if g .phase (v ) in (0 ,1 ))
93
+ pauli_y = set (v for v in vertices if g .phase (v ) in (Fraction (1 ,2 ),Fraction (- 1 ,2 )))
91
94
92
95
processed : Set [VT ] = pattern_outputs .copy () | g .grounds ()
93
96
non_outputs = list (vertices .difference (pattern_outputs ))
@@ -100,7 +103,7 @@ def gflow(
100
103
correct : Set [VT ] = set ()
101
104
processed_prime = [
102
105
v
103
- for v in (processed | paulis ).difference (pattern_inputs )
106
+ for v in (processed | pauli_x | pauli_y ).difference (pattern_inputs )
104
107
if focus or any (w not in processed for w in g .neighbors (v ))
105
108
]
106
109
0 commit comments