Skip to content

Commit

Permalink
ClExprOp and friends (#1628)
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-alec authored Oct 23, 2024
1 parent 7f768de commit 201c94f
Show file tree
Hide file tree
Showing 24 changed files with 2,382 additions and 51 deletions.
1 change: 1 addition & 0 deletions pytket/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ pybind11_add_module(circuit
binders/circuit/Circuit/add_op.cpp
binders/circuit/Circuit/main.cpp
binders/circuit/classical.cpp
binders/circuit/clexpr.cpp
binders/circuit/main.cpp
${HEADER_FILES})
target_include_directories(circuit PRIVATE binders/include)
Expand Down
16 changes: 16 additions & 0 deletions pytket/binders/circuit/Circuit/add_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
// limitations under the License.

#include <pybind11/pybind11.h>
#include <pybind11/pytypes.h>
#include <pybind11/stl.h>

#include <memory>
#include <optional>
#include <vector>

Expand All @@ -33,6 +35,7 @@
#include "tket/Circuit/ToffoliBox.hpp"
#include "tket/Converters/PhasePoly.hpp"
#include "tket/Gate/OpPtrFunctions.hpp"
#include "tket/Ops/ClExpr.hpp"
#include "tket/Utils/UnitID.hpp"
#include "typecast.hpp"
namespace py = pybind11;
Expand Down Expand Up @@ -483,6 +486,19 @@ void init_circuit_add_op(py::class_<Circuit, std::shared_ptr<Circuit>> &c) {
":param args: Indices of the qubits to append the box to"
"\n:return: the new :py:class:`Circuit`",
py::arg("expression"), py::arg("target"))
.def(
"add_clexpr",
[](Circuit *circ, const WiredClExpr &expr,
const py::tket_custom::SequenceVec<Bit> &args,
const py::kwargs &kwargs) {
Op_ptr op = std::make_shared<ClExprOp>(expr);
return add_gate_method<Bit>(circ, op, args, kwargs);
},
"Append a :py:class:`WiredClExpr` to the circuit.\n\n"
":param expr: The expression to append\n"
":param args: The bits to apply the expression to\n"
":return: the new :py:class:`Circuit`",
py::arg("expr"), py::arg("args"))
.def(
"add_custom_gate",
[](Circuit *circ, const composite_def_ptr_t &definition,
Expand Down
Loading

0 comments on commit 201c94f

Please sign in to comment.