Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Match symbolic phase gadgets #132

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pyzx/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,12 @@ def match_phase_gadgets(g: BaseGraph[VT,ET]) -> List[MatchGadgetType[VT]]:
outputs = g.outputs()
# First we find all the phase-gadgets, and the list of vertices they act on
for v in g.vertices():
if phases[v] != 0 and hasattr(phases[v], 'denominator') and phases[v].denominator > 2 and len(list(g.neighbors(v)))==1:
non_clifford = phases[v] != 0 and getattr(phases[v], 'denominator', 1) > 2
try: # symbol check
float(phases[v])
except:
non_clifford = True
if non_clifford and len(list(g.neighbors(v)))==1:
n = list(g.neighbors(v))[0]
if phases[n] not in (0,1): continue # Not a real phase gadget (happens for scalar diagrams)
if n in gadgets: continue # Not a real phase gadget (happens for scalar diagrams)
Expand Down