diff --git a/.github/workflows/build-without-conan.yml b/.github/workflows/build-without-conan.yml index c31470cc7a..9544d442a3 100644 --- a/.github/workflows/build-without-conan.yml +++ b/.github/workflows/build-without-conan.yml @@ -40,9 +40,9 @@ jobs: - name: Install symengine run: | cd ${TMP_DIR} - wget https://github.com/symengine/symengine/archive/refs/tags/v0.12.0.tar.gz - tar xzvf v0.12.0.tar.gz - cd symengine-0.12.0/ + wget https://github.com/symengine/symengine/archive/refs/tags/v0.13.0.tar.gz + tar xzvf v0.13.0.tar.gz + cd symengine-0.13.0/ mkdir build cd build cmake -GNinja -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTS=OFF -DBUILD_BENCHMARKS=OFF .. diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 5ada774af1..a870b45a61 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -428,7 +428,7 @@ jobs: python -m pip install -U mypy pybind11-stubgen cd pytket ./stub_generation/regenerate_stubs - git diff --quiet pytket/_tket && echo "Stubs are up-to-date" || exit 1 # fail if stubs change after regeneration + git diff pytket/_tket && echo "Stubs are up-to-date" || exit 1 # fail if stubs change after regeneration python -m mypy --config-file=mypy.ini --no-incremental -p pytket -p tests - name: Upload package if: github.event_name == 'push' && needs.check_changes.outputs.tket_changed == 'true' diff --git a/build-without-conan.md b/build-without-conan.md index 9a91f1f50f..4663f65ed1 100644 --- a/build-without-conan.md +++ b/build-without-conan.md @@ -48,9 +48,9 @@ make install ``` cd ${TMP_DIR} -wget https://github.com/symengine/symengine/archive/refs/tags/v0.12.0.tar.gz -tar xzvf v0.12.0.tar.gz -cd symengine-0.12.0/ +wget https://github.com/symengine/symengine/archive/refs/tags/v0.13.0.tar.gz +tar xzvf v0.13.0.tar.gz +cd symengine-0.13.0/ mkdir build cd build cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTS=OFF -DBUILD_BENCHMARKS=OFF .. diff --git a/pytket/binders/circuit/Circuit/add_op.cpp b/pytket/binders/circuit/Circuit/add_op.cpp index c8c952d2f3..7c9000d85e 100644 --- a/pytket/binders/circuit/Circuit/add_op.cpp +++ b/pytket/binders/circuit/Circuit/add_op.cpp @@ -414,6 +414,11 @@ void init_circuit_add_op(py::class_> &c) { [](Circuit *circ, const py::tket_custom::BitLogicExpression &exp, const py::tket_custom::SequenceVec &outputs, const py::kwargs &kwargs) { + PyErr_WarnEx( + PyExc_DeprecationWarning, + "The add_classicalexpbox_bit method is deprecated. Please use " + "Circuit::add_clexpr() instead.", + 1); auto inputs = exp.attr("all_inputs")().cast>(); py::tket_custom::SequenceVec o_vec, io_vec; @@ -439,7 +444,9 @@ void init_circuit_add_op(py::class_> &c) { n_i, n_io, n_o, exp), o_vec, kwargs); }, - "Append a :py:class:`ClassicalExpBox` over Bit to the circuit.\n\n" + "Append a :py:class:`ClassicalExpBox` over Bit to the circuit.\n" + "DEPRECATED: Please use :py:meth:`add_clexpr` instead. This method " + "will be removed after pytket 1.40.\n\n" ":param classicalexpbox: The box to append\n" ":param args: Indices of the qubits to append the box to" "\n:return: the new :py:class:`Circuit`", @@ -450,6 +457,11 @@ void init_circuit_add_op(py::class_> &c) { const py::tket_custom::BitRegisterLogicExpression &exp, const py::tket_custom::SequenceVec &outputs, const py::kwargs &kwargs) { + PyErr_WarnEx( + PyExc_DeprecationWarning, + "The add_classicalexpbox_register method is deprecated. Please " + "use Circuit::add_clexpr() instead.", + 1); auto inputs = exp.attr("all_inputs")().cast>(); std::set all_bits; @@ -481,7 +493,9 @@ void init_circuit_add_op(py::class_> &c) { o_vec, kwargs); }, "Append a :py:class:`ClassicalExpBox` over BitRegister to the " - "circuit.\n\n" + "circuit.\n" + "DEPRECATED: Please use :py:meth:`add_clexpr` instead. This method " + "will be removed after pytket 1.40.\n\n" ":param classicalexpbox: The box to append\n" ":param args: Indices of the qubits to append the box to" "\n:return: the new :py:class:`Circuit`", diff --git a/pytket/binders/circuit/main.cpp b/pytket/binders/circuit/main.cpp index ba4d2853f3..cf32612f4d 100644 --- a/pytket/binders/circuit/main.cpp +++ b/pytket/binders/circuit/main.cpp @@ -525,7 +525,9 @@ PYBIND11_MODULE(circuit, m) { "A classical operation applied to multiple bits simultaneously") .value( "ClassicalExpBox", OpType::ClassicalExpBox, - "A box for holding compound classical operations on Bits.") + "A box for holding compound classical operations on Bits.\n" + "DEPRECATED: Please use :py:class:`WiredClExpr` instead. This class " + "will be removed after pytket 1.40.") .value( "MultiplexorBox", OpType::MultiplexorBox, "A multiplexor (i.e. uniformly controlled operations)") diff --git a/pytket/conanfile.py b/pytket/conanfile.py index 08c6f2c24b..9b76b1cb1a 100644 --- a/pytket/conanfile.py +++ b/pytket/conanfile.py @@ -36,9 +36,9 @@ def requirements(self): self.requires("nlohmann_json/3.11.3") self.requires("pybind11/2.13.6") self.requires("pybind11_json/0.2.14") - self.requires("symengine/0.12.0") + self.requires("symengine/0.13.0") self.requires("tkassert/0.3.4@tket/stable") - self.requires("tket/1.3.45@tket/stable") + self.requires("tket/1.3.47@tket/stable") self.requires("tklog/0.3.3@tket/stable") self.requires("tkrng/0.3.3@tket/stable") self.requires("tktokenswap/0.3.9@tket/stable") diff --git a/pytket/docs/changelog.rst b/pytket/docs/changelog.rst index 7c851aaf33..f49bb0c37e 100644 --- a/pytket/docs/changelog.rst +++ b/pytket/docs/changelog.rst @@ -18,6 +18,11 @@ Features: and `flatten_registers` * Add new pass `MultiThreadGreedyPauliSimp`. * Implement `dagger()` and `transpose()` for `CustomGate`. +* Use `ClExprOp` by default when converting from QASM. + +Deprecations: + +* Deprecate `ClassicalExpBox` and related methods, in favour of `ClExprOp`. Fixes: diff --git a/pytket/pytket/_tket/circuit.pyi b/pytket/pytket/_tket/circuit.pyi index 842014cd50..f8c5649089 100644 --- a/pytket/pytket/_tket/circuit.pyi +++ b/pytket/pytket/_tket/circuit.pyi @@ -1438,6 +1438,7 @@ class Circuit: def add_classicalexpbox_bit(self, expression: pytket.circuit.logic_exp.BitLogicExp, target: typing.Sequence[pytket._tket.unit_id.Bit], **kwargs: Any) -> Circuit: """ Append a :py:class:`ClassicalExpBox` over Bit to the circuit. + DEPRECATED: Please use :py:meth:`add_clexpr` instead. This method will be removed after pytket 1.40. :param classicalexpbox: The box to append :param args: Indices of the qubits to append the box to @@ -1446,6 +1447,7 @@ class Circuit: def add_classicalexpbox_register(self, expression: pytket.circuit.logic_exp.RegLogicExp, target: typing.Sequence[pytket._tket.unit_id.Bit], **kwargs: Any) -> Circuit: """ Append a :py:class:`ClassicalExpBox` over BitRegister to the circuit. + DEPRECATED: Please use :py:meth:`add_clexpr` instead. This method will be removed after pytket 1.40. :param classicalexpbox: The box to append :param args: Indices of the qubits to append the box to @@ -3619,6 +3621,7 @@ class OpType: MultiBit : A classical operation applied to multiple bits simultaneously ClassicalExpBox : A box for holding compound classical operations on Bits. + DEPRECATED: Please use :py:class:`WiredClExpr` instead. This class will be removed after pytket 1.40. MultiplexorBox : A multiplexor (i.e. uniformly controlled operations) diff --git a/pytket/pytket/qasm/qasm.py b/pytket/pytket/qasm/qasm.py index e7fadaa2eb..605689dd1c 100644 --- a/pytket/pytket/qasm/qasm.py +++ b/pytket/pytket/qasm/qasm.py @@ -296,7 +296,7 @@ def __init__( self, return_gate_dict: bool = False, maxwidth: int = 32, - use_clexpr: bool = False, + use_clexpr: bool = True, ) -> None: super().__init__() self.q_registers: dict[str, int] = {} @@ -978,7 +978,7 @@ def circuit_from_qasm( input_file: Union[str, "os.PathLike[Any]"], encoding: str = "utf-8", maxwidth: int = 32, - use_clexpr: bool = False, + use_clexpr: bool = True, ) -> Circuit: """A method to generate a tket Circuit from a qasm file. @@ -1000,7 +1000,7 @@ def circuit_from_qasm( def circuit_from_qasm_str( - qasm_str: str, maxwidth: int = 32, use_clexpr: bool = False + qasm_str: str, maxwidth: int = 32, use_clexpr: bool = True ) -> Circuit: """A method to generate a tket Circuit from a qasm string. @@ -1023,7 +1023,7 @@ def circuit_from_qasm_str( def circuit_from_qasm_io( - stream_in: TextIO, maxwidth: int = 32, use_clexpr: bool = False + stream_in: TextIO, maxwidth: int = 32, use_clexpr: bool = True ) -> Circuit: """A method to generate a tket Circuit from a qasm text stream""" return circuit_from_qasm_str( @@ -1036,7 +1036,7 @@ def circuit_from_qasm_wasm( wasm_file: Union[str, "os.PathLike[Any]"], encoding: str = "utf-8", maxwidth: int = 32, - use_clexpr: bool = False, + use_clexpr: bool = True, ) -> Circuit: """A method to generate a tket Circuit from a qasm string and external WASM module. diff --git a/tket/conanfile.py b/tket/conanfile.py index 0ead0c1ca5..c479bca357 100644 --- a/tket/conanfile.py +++ b/tket/conanfile.py @@ -23,7 +23,7 @@ class TketConan(ConanFile): name = "tket" - version = "1.3.45" + version = "1.3.47" package_type = "library" license = "Apache 2" homepage = "https://github.com/CQCL/tket" @@ -114,7 +114,7 @@ def requirements(self): self.requires("boost/1.86.0", transitive_headers=True) self.requires("eigen/3.4.0", transitive_headers=True) self.requires("nlohmann_json/3.11.3", transitive_headers=True) - self.requires("symengine/0.12.0", transitive_headers=True) + self.requires("symengine/0.13.0", transitive_headers=True) self.requires("tkassert/0.3.4@tket/stable", transitive_headers=True) self.requires("tklog/0.3.3@tket/stable") self.requires("tkrng/0.3.3@tket/stable")