diff --git a/pytket/conanfile.py b/pytket/conanfile.py index cd0a84ddc8..62a6ab520b 100644 --- a/pytket/conanfile.py +++ b/pytket/conanfile.py @@ -32,7 +32,7 @@ def package(self): cmake.install() def requirements(self): - self.requires("tket/1.2.61@tket/stable") + self.requires("tket/1.2.62@tket/stable") self.requires("tklog/0.3.3@tket/stable") self.requires("tkrng/0.3.3@tket/stable") self.requires("tkassert/0.3.3@tket/stable") diff --git a/pytket/docs/changelog.rst b/pytket/docs/changelog.rst index 9302665149..97187302c3 100644 --- a/pytket/docs/changelog.rst +++ b/pytket/docs/changelog.rst @@ -14,6 +14,8 @@ Fixes: * When converting QASM expressions to ``ClassicalExpBox``, preserve the ordering of the bits in the expression in the resulting ``cmd.args`` +* Fix incorrect serialisation of ``PauliExpPairBox`` when the Pauli strings are of + length 2. 1.21.0 (October 2023) --------------------- diff --git a/pytket/tests/circuit_test.py b/pytket/tests/circuit_test.py index f28970d688..9b0804c78f 100644 --- a/pytket/tests/circuit_test.py +++ b/pytket/tests/circuit_test.py @@ -48,6 +48,7 @@ Bit, BitRegister, QubitRegister, + CXConfigType, ) from pytket.circuit.display import get_circuit_renderer, render_circuit_as_html from pytket.circuit.named_types import ( @@ -674,6 +675,15 @@ def test_boxes() -> None: command.op.get_unitary() +def test_pauliexp_pair_box_serialisation() -> None: + # https://github.com/CQCL/tket/issues/1084 + p = PauliExpPairBox( + [Pauli.Z, Pauli.X], 0.5, [Pauli.X, Pauli.Z], 0.2, CXConfigType.MultiQGate + ) + c = Circuit(2).add_pauliexppairbox(p, [0, 1]) + assert json_validate(c) + + def test_tofollibox_strats() -> None: permutation = [ ([_0, _0, _0, _0], [_1, _1, _1, _1]), @@ -1261,3 +1271,4 @@ def test_phase_order() -> None: test_measuring_registers() test_multi_controlled_gates() test_counting_n_qubit_gates() + test_pauliexp_pair_box_serialisation() diff --git a/tket/conanfile.py b/tket/conanfile.py index 33e83395b6..dfad9fefba 100644 --- a/tket/conanfile.py +++ b/tket/conanfile.py @@ -23,7 +23,7 @@ class TketConan(ConanFile): name = "tket" - version = "1.2.61" + version = "1.2.62" package_type = "library" license = "Apache 2" homepage = "https://github.com/CQCL/tket" diff --git a/tket/src/Circuit/PauliExpBoxes.cpp b/tket/src/Circuit/PauliExpBoxes.cpp index 85f1992847..22f9734048 100644 --- a/tket/src/Circuit/PauliExpBoxes.cpp +++ b/tket/src/Circuit/PauliExpBoxes.cpp @@ -190,7 +190,12 @@ bool PauliExpPairBox::is_equal(const Op &op_other) const { nlohmann::json PauliExpPairBox::to_json(const Op_ptr &op) { const auto &box = static_cast(*op); nlohmann::json j = core_box_json(box); - j["paulis_pair"] = box.get_paulis_pair(); + auto paulis_pair = box.get_paulis_pair(); + // use vector to avoid serialising into a dictionary if the Pauli strings are + // of length 2 + std::vector> paulis_vec{ + paulis_pair.first, paulis_pair.second}; + j["paulis_pair"] = paulis_vec; j["phase_pair"] = box.get_phase_pair(); j["cx_config"] = box.get_cx_config(); return j;