Skip to content

Commit b6701a6

Browse files
committed
wip Pauli Y support
1 parent c8b45b6 commit b6701a6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pyzx/gflow.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
from fractions import Fraction
1718
from typing import Dict, Set, Tuple, Optional
1819

1920
from .extract import bi_adj
@@ -76,7 +77,8 @@ def gflow(
7677
vertices: Set[VT] = set(v for v in g.vertices() if vertex_is_zx(ty[v]))
7778
pattern_inputs: Set[VT] = set()
7879
pattern_outputs: Set[VT] = set()
79-
paulis: Set[VT] = set()
80+
pauli_x: Set[VT] = set()
81+
pauli_y: Set[VT] = set()
8082

8183
for inp in g.inputs():
8284
pattern_inputs |= set(n for n in g.neighbors(inp) if vertex_is_zx(ty[n]))
@@ -87,7 +89,8 @@ def gflow(
8789
pattern_inputs, pattern_outputs = pattern_outputs, pattern_inputs
8890

8991
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)))
9194

9295
processed: Set[VT] = pattern_outputs.copy() | g.grounds()
9396
non_outputs = list(vertices.difference(pattern_outputs))
@@ -100,7 +103,7 @@ def gflow(
100103
correct: Set[VT] = set()
101104
processed_prime = [
102105
v
103-
for v in (processed | paulis).difference(pattern_inputs)
106+
for v in (processed | pauli_x | pauli_y).difference(pattern_inputs)
104107
if focus or any(w not in processed for w in g.neighbors(v))
105108
]
106109

0 commit comments

Comments
 (0)