Skip to content

Commit

Permalink
add test for different wasm uid
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-melf committed Nov 22, 2024
1 parent a27a7d8 commit 8c28202
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
5 changes: 1 addition & 4 deletions pytket/pytket/circuit/decompose_classical.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,7 @@ def _decompose_expressions(circ: Circuit) -> tuple[Circuit, bool]:
newcirc.add_barrier(args)
else:
for arg in args:
if (
isinstance(arg, Bit)
and arg not in newcirc.bits
):
if isinstance(arg, Bit) and arg not in newcirc.bits:
newcirc.add_bit(arg)
newcirc.add_gate(op, args, **kwargs)
return newcirc, modified
19 changes: 19 additions & 0 deletions pytket/tests/classical_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,25 @@ def test_wasm_append_2() -> None:
assert d.depth() == 3


def test_wasm_append_3() -> None:
wfh = wasm.WasmFileHandler("testfile.wasm")
wfh2 = wasm.WasmFileHandler("testfile-without-init.wasm", check_file=False)

c = Circuit(1)
a = c.add_c_register("a", 8)
c.add_wasm_to_reg("add_one", wfh, [a], [a])
assert c.depth() == 1

d = Circuit()
for bit in c.bits:
d.add_bit(bit)
d.add_c_setbits([False], [bit])
d.add_wasm_to_reg("no_return", wfh2, [a], [])

with pytest.raises(ValueError):
d.append(c)


def test_wasmfilehandler_without_init() -> None:
with pytest.raises(ValueError):
_ = wasm.WasmFileHandler("testfile-without-init.wasm")
Expand Down

0 comments on commit 8c28202

Please sign in to comment.