Skip to content

Commit

Permalink
Add y gate based on ry gate.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlyongemallo committed Sep 17, 2023
1 parent 53c2361 commit 8061f3e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions pyzx/circuit/gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,15 @@ def to_graph(self, g, q_mapper, c_mapper):
def tcount(self):
return 1 if self.phase.denominator > 2 else 0

class Y(YPhase):
name = 'Y'
qasm_name = 'y'
qc_name = 'Y'
quipper_name = 'Y'
print_phase = False
def __init__(self, target: int) -> None:
super().__init__(target, phase = Fraction(1,1))

class NOT(XPhase):
name = 'NOT'
qasm_name = 'x'
Expand Down Expand Up @@ -990,6 +999,7 @@ def to_graph(self, g, q_mapper, c_mapper):

qasm_gate_table: Dict[str, Type[Gate]] = {
"x": NOT,
"y": Y,
"z": Z,
"s": S,
"t": T,
Expand Down
2 changes: 1 addition & 1 deletion pyzx/circuit/qasmparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def parse_command(self, c: str, registers: Dict[str,Tuple[int,int]]) -> List[Gat
for g in circ.gates:
gates.append(g.reposition(argset))
continue
if name in ('x', 'z', 's', 't', 'h', 'sdg', 'tdg'):
if name in ('x', 'y', 'z', 's', 't', 'h', 'sdg', 'tdg'):
if name in ('sdg', 'tdg'):
g = qasm_gate_table[name](argset[0],adjoint=True) # type: ignore # mypy can't handle -
else: g = qasm_gate_table[name](argset[0]) # type: ignore # - Gate subclasses with different numbers of parameters
Expand Down

0 comments on commit 8061f3e

Please sign in to comment.