Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClExprOp and friends #1628

Merged
merged 9 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading