Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python: ["3.10", "3.11", "3.12", "3.13"]

name: "Python ${{ matrix.python }} / ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
Expand Down
5 changes: 4 additions & 1 deletion graphix_qasm_parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
ParserRuleContext,
)
from graphix import Circuit
from graphix.instruction import CCX, CNOT, RX, RY, RZ, RZZ, SWAP, H, I, S, X, Y, Z
from graphix.instruction import CCX, CNOT, CZ, RX, RY, RZ, RZZ, SWAP, H, I, S, X, Y, Z
from openqasm_parser import qasm3Lexer, qasm3Parser, qasm3ParserVisitor

# override introduced in Python 3.12
Expand Down Expand Up @@ -302,6 +302,9 @@ def visitGateCallStatement(self, ctx: qasm3Parser.GateCallStatementContext) -> N
elif gate == "swap":
# https://openqasm.com/language/standard_library.html#swap
instruction = SWAP(targets=(operands[0], operands[1]))
elif gate == "cz":
# https://openqasm.com/language/standard_library.html#cz
instruction = CZ(targets=(operands[0], operands[1]))
elif gate == "h":
# https://openqasm.com/language/standard_library.html#h
instruction = H(target=operands[0])
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
graphix>=0.3.1
graphix @ git+https://github.com/TeamGraphix/graphix.git@add_cz_instruction
openqasm-parser>=3.1.0
6 changes: 5 additions & 1 deletion tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import math

import pytest
from graphix.instruction import CCX, CNOT, RX, RY, RZ, RZZ, SWAP, H, S, X, Y, Z
from graphix.instruction import CCX, CNOT, CZ, RX, RY, RZ, RZZ, SWAP, H, S, X, Y, Z

from graphix_qasm_parser import OpenQASMParser

Expand Down Expand Up @@ -51,6 +51,7 @@ def test_parse_all_instructions() -> None: # noqa: PLR0915
crz(pi/3) q[0], q[1];
cx q[0], q[1];
swap q[0], q[1];
cz q[0], q[1];
h q[0];
s q[0];
x q[0];
Expand Down Expand Up @@ -82,6 +83,9 @@ def test_parse_all_instructions() -> None: # noqa: PLR0915
assert isinstance(instruction, SWAP)
assert instruction.targets == (0, 1)
instruction = next(iterator)
assert isinstance(instruction, CZ)
assert instruction.targets == (0, 1)
instruction = next(iterator)
assert isinstance(instruction, H)
assert instruction.target == 0
instruction = next(iterator)
Expand Down