Skip to content

Commit

Permalink
fix(phirgen): float not str for duration
Browse files Browse the repository at this point in the history
  • Loading branch information
qartik committed Mar 7, 2024
1 parent 5d8ac2e commit 63a8d7b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ classifiers = [
]
dynamic = ["version"]
dependencies = [
"phir>=0.3.1",
"phir>=0.3.2",
"pytket>=1.21.0",
"wasmtime>=15.0.0",
]
Expand Down
2 changes: 1 addition & 1 deletion pytket/phir/phirgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/test_phirgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"]}

0 comments on commit 63a8d7b

Please sign in to comment.