From 9eff38ee9ccd9625cf1cd465af1a40357a1e180f Mon Sep 17 00:00:00 2001 From: Artem Demchenko Date: Thu, 16 Nov 2023 23:26:14 +0300 Subject: [PATCH] Implement python bindings for UCCVerifier Co-authored-by: Ivan Volgushev Co-authored-by: Artem Demchenko --- src/python_bindings/bindings.cpp | 7 +++++++ src/python_bindings/py_ucc_verifier.h | 30 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/python_bindings/py_ucc_verifier.h diff --git a/src/python_bindings/bindings.cpp b/src/python_bindings/bindings.cpp index 141d935447..428b3e424b 100644 --- a/src/python_bindings/bindings.cpp +++ b/src/python_bindings/bindings.cpp @@ -45,6 +45,7 @@ #include "py_fd_verifier.h" #include "py_metric_verifier.h" #include "py_ucc_algorithm.h" +#include "py_ucc_verifier.h" INITIALIZE_EASYLOGGINGPP @@ -160,6 +161,12 @@ PYBIND11_MODULE(desbordante, module) { .def("get_num_error_rows", &PyFDVerifier::GetNumErrorRows) .def("get_highlights", &PyFDVerifier::GetHighlights); + DEFINE_ALGORITHM(UCCVerifier, Algorithm) + .def("ucc_holds", &PyUCCVerifier::UCCHolds) + .def("get_num_clusters_not_ucc", &PyUCCVerifier::GetNumClustersNotUCC) + .def("get_num_rows_not_ucc", &PyUCCVerifier::GetNumRowsNotUCC) + .def("get_clusters_not_ucc", &PyUCCVerifier::GetClustersNotUCC); + DEFINE_ALGORITHM(DataStats, Algorithm).def("get_result_string", &PyDataStats::GetResultString); DEFINE_ALGORITHM(MetricVerifier, Algorithm).def("mfd_holds", &PyMetricVerifier::MfdHolds); diff --git a/src/python_bindings/py_ucc_verifier.h b/src/python_bindings/py_ucc_verifier.h new file mode 100644 index 0000000000..6d1aa12d40 --- /dev/null +++ b/src/python_bindings/py_ucc_verifier.h @@ -0,0 +1,30 @@ +#pragma once + +#include "algorithms/ucc/ucc_verifier/ucc_verifier.h" +#include "get_algorithm.h" +#include "py_algorithm.h" + +namespace python_bindings { + +class PyUCCVerifier : public PyAlgorithm { + using PyAlgorithmBase::algorithm_; + +public: + [[nodiscard]] bool UCCHolds() const { + return GetAlgorithm(algorithm_).UCCHolds(); + } + + [[nodiscard]] size_t GetNumClustersNotUCC() const { + return GetAlgorithm(algorithm_).GetNumClustersNotUCC(); + } + + [[nodiscard]] size_t GetNumRowsNotUCC() const { + return GetAlgorithm(algorithm_).GetNumRowsNotUCC(); + } + + [[nodiscard]] std::vector GetClustersNotUCC() const { + return GetAlgorithm(algorithm_).GetClustersNotUCC(); + } +}; + +} // namespace python_bindings