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 3df72b2788..08c6f2c24b 100644 --- a/pytket/conanfile.py +++ b/pytket/conanfile.py @@ -38,7 +38,7 @@ def requirements(self): self.requires("pybind11_json/0.2.14") self.requires("symengine/0.12.0") self.requires("tkassert/0.3.4@tket/stable") - self.requires("tket/1.3.44@tket/stable") + self.requires("tket/1.3.45@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 04a6373000..fa8320bcdf 100644 --- a/pytket/docs/changelog.rst +++ b/pytket/docs/changelog.rst @@ -17,6 +17,11 @@ Features: * Add option to not relabel `ClassicalExpBox` when calling `rename_units` and `flatten_registers` * 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 dc0b961750..0ead0c1ca5 100644 --- a/tket/conanfile.py +++ b/tket/conanfile.py @@ -23,7 +23,7 @@ class TketConan(ConanFile): name = "tket" - version = "1.3.44" + version = "1.3.45" package_type = "library" license = "Apache 2" homepage = "https://github.com/CQCL/tket"