From 63a8d7b08eb4fdc7a22ae3d362c1d8a8ce53ea1e Mon Sep 17 00:00:00 2001 From: Kartik Singhal Date: Thu, 7 Mar 2024 16:46:44 -0700 Subject: [PATCH] fix(phirgen): float not str for duration --- pyproject.toml | 2 +- pytket/phir/phirgen.py | 2 +- requirements.txt | 2 +- tests/test_phirgen.py | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 35e5a5b..1e30d90 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ classifiers = [ ] dynamic = ["version"] dependencies = [ - "phir>=0.3.1", + "phir>=0.3.2", "pytket>=1.21.0", "wasmtime>=15.0.0", ] diff --git a/pytket/phir/phirgen.py b/pytket/phir/phirgen.py index 7328a4e..a0d35c9 100644 --- a/pytket/phir/phirgen.py +++ b/pytket/phir/phirgen.py @@ -234,7 +234,7 @@ def convert_subcmd(op: tk.Op, cmd: tk.Command) -> JsonDict | None: out = { "mop": "Idle", "args": [arg_to_bit(qbit) for qbit in cmd.qubits], - "duration": (dur, "s"), + "duration": (float(dur), "s"), } case "order" | "group": raise NotImplementedError(op.data) diff --git a/requirements.txt b/requirements.txt index bd42795..3b3b696 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ build==1.1.1 mypy==1.8.0 networkx==2.8.8 -phir==0.3.1 +phir==0.3.2 pre-commit==3.6.2 pydata_sphinx_theme==0.15.2 pytest==8.0.2 diff --git a/tests/test_phirgen.py b/tests/test_phirgen.py index 995137f..7b4eba5 100644 --- a/tests/test_phirgen.py +++ b/tests/test_phirgen.py @@ -132,7 +132,7 @@ def test_sleep_idle() -> None: """Ensure sleep from qasm gets converted to PHIR Idle Mop.""" circ = get_qasm_as_circuit(QasmFile.sleep) phir = json.loads(pytket_to_phir(circ)) - assert phir["ops"][7] == {"mop": "Idle", "args": [["q", 0]], "duration": ["1", "s"]} + assert phir["ops"][7] == {"mop": "Idle", "args": [["q", 0]], "duration": [1.0, "s"]} def test_multiple_sleep() -> None: @@ -148,5 +148,5 @@ def test_multiple_sleep() -> None: """ circ = circuit_from_qasm_str(qasm) phir = json.loads(pytket_to_phir(circ)) - assert phir["ops"][2] == {"mop": "Idle", "args": [["q", 0]], "duration": ["1", "s"]} - assert phir["ops"][4] == {"mop": "Idle", "args": [["q", 1]], "duration": ["2", "s"]} + assert phir["ops"][2] == {"mop": "Idle", "args": [["q", 0]], "duration": [1.0, "s"]} + assert phir["ops"][4] == {"mop": "Idle", "args": [["q", 1]], "duration": [2.0, "s"]}