Skip to content

Commit

Permalink
make wasm uid option in python
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-melf committed Nov 22, 2024
1 parent 82ed8c5 commit de111a1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
10 changes: 9 additions & 1 deletion pytket/binders/circuit/Circuit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,15 @@ void def_circuit(py::class_<Circuit, std::shared_ptr<Circuit>> &pyCircuit) {
"n_gates", &Circuit::n_gates,
":return: the number of gates in the Circuit")
.def_property_readonly(
"wasm_uid", &Circuit::get_wasm_file_uid,
"wasm_uid",
[](const Circuit &circ) {
std::optional<std::string> result;
try {
result = circ.get_wasm_file_uid();
} catch (const std::exception &) {
}
return result;
},
":return: the unique wasm uid of the circuit")
.def_property_readonly(
"n_qubits", &Circuit::n_qubits,
Expand Down
4 changes: 2 additions & 2 deletions pytket/pytket/_tket/circuit.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2572,9 +2572,9 @@ class Circuit:
A list of all qubit ids in the circuit
"""
@property
def wasm_uid(self) -> str:
def wasm_uid(self) -> str | None:
"""
:return: the wasm uid of the first wasmop found in the circuit
:return: the unique wasm uid of the circuit
"""
class ClBitVar:
"""
Expand Down
3 changes: 1 addition & 2 deletions pytket/tests/classical_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,7 @@ def test_wasm_uid_from_circuit_5() -> None:
c = Circuit(0, 6)

assert c.depth() == 0
with pytest.raises(ValueError):
c.wasm_uid
assert c.wasm_uid is None


def test_wasm_append() -> None:
Expand Down

0 comments on commit de111a1

Please sign in to comment.