Skip to content

Commit

Permalink
wip Pauli Y support
Browse files Browse the repository at this point in the history
  • Loading branch information
akissinger committed Dec 22, 2024
1 parent c8b45b6 commit b6701a6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pyzx/gflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from fractions import Fraction
from typing import Dict, Set, Tuple, Optional

from .extract import bi_adj
Expand Down Expand Up @@ -76,7 +77,8 @@ def gflow(
vertices: Set[VT] = set(v for v in g.vertices() if vertex_is_zx(ty[v]))
pattern_inputs: Set[VT] = set()
pattern_outputs: Set[VT] = set()
paulis: Set[VT] = set()
pauli_x: Set[VT] = set()
pauli_y: Set[VT] = set()

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

if pauli:
paulis = set(v for v in vertices.difference(pattern_inputs) if g.phase(v) in (0,1))
pauli_x = set(v for v in vertices if g.phase(v) in (0,1))
pauli_y = set(v for v in vertices if g.phase(v) in (Fraction(1,2),Fraction(-1,2)))

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

Expand Down

0 comments on commit b6701a6

Please sign in to comment.