From 97957fdf22a3f7f197c34bbf2fc61601a2951eb5 Mon Sep 17 00:00:00 2001 From: Michael Sinelnikov Date: Mon, 1 Jan 2024 16:51:57 +0300 Subject: [PATCH] Add python bindings for Split algorithm --- src/python_bindings/bindings.cpp | 3 ++- src/python_bindings/dd/bind_split.cpp | 25 +++++++++++++++++++++++++ src/python_bindings/dd/bind_split.h | 7 +++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/python_bindings/dd/bind_split.cpp create mode 100644 src/python_bindings/dd/bind_split.h diff --git a/src/python_bindings/bindings.cpp b/src/python_bindings/bindings.cpp index 3ca1d6a26e..c3c0ac798e 100644 --- a/src/python_bindings/bindings.cpp +++ b/src/python_bindings/bindings.cpp @@ -8,6 +8,7 @@ #include "bind_main_classes.h" #include "cfd/bind_cfd.h" #include "data/bind_data_types.h" +#include "dd/bind_split.h" #include "fd/bind_fd.h" #include "fd/bind_fd_verification.h" #include "gfd/bind_gfd_verification.h" @@ -35,7 +36,7 @@ PYBIND11_MODULE(desbordante, module) { for (auto bind_func : {BindMainClasses, BindDataTypes, BindFd, BindCfd, BindAr, BindUcc, BindAc, BindOd, BindFdVerification, BindMfdVerification, BindUccVerification, - BindStatistics, BindInd, BindGfdVerification}) { + BindStatistics, BindInd, BindGfdVerification, BindSplit}) { bind_func(module); } } diff --git a/src/python_bindings/dd/bind_split.cpp b/src/python_bindings/dd/bind_split.cpp new file mode 100644 index 0000000000..e31846e1ce --- /dev/null +++ b/src/python_bindings/dd/bind_split.cpp @@ -0,0 +1,25 @@ +#include "bind_split.h" + +#include +#include + +#include "algorithms/dd/dd.h" +#include "algorithms/dd/mining_algorithms.h" +#include "py_util/bind_primitive.h" + +namespace { +namespace py = pybind11; +} // namespace + +namespace python_bindings { +void BindSplit(py::module_& main_module) { + using namespace algos; + + auto dd_module = main_module.def_submodule("dd"); + py::class_(dd_module, "DD") + .def("__str__", &model::DDString::ToString) + .def("__repr__", &model::DDString::ToString); + + BindPrimitiveNoBase(dd_module, "Split").def("get_dds", &dd::Split::GetDDStringList); +} +} // namespace python_bindings diff --git a/src/python_bindings/dd/bind_split.h b/src/python_bindings/dd/bind_split.h new file mode 100644 index 0000000000..39c81b18bf --- /dev/null +++ b/src/python_bindings/dd/bind_split.h @@ -0,0 +1,7 @@ +#pragma once + +#include + +namespace python_bindings { +void BindSplit(pybind11::module_& main_module); +} // namespace python_bindings