diff --git a/examples/comparison_pfd_vs_afd.py b/examples/comparison_pfd_vs_afd.py index 07cfb7657d..3fe026ed77 100644 --- a/examples/comparison_pfd_vs_afd.py +++ b/examples/comparison_pfd_vs_afd.py @@ -26,8 +26,8 @@ def get_pfds(): pfds = set(get_pfds()) afds = set(get_afds()) -print("pFDs \ AFDs =", stringify(pfds - afds)) -print("AFDs \ pFDs =", stringify(afds - pfds)) +print("pFDs \\ AFDs =", stringify(pfds - afds)) +print("AFDs \\ pFDs =", stringify(afds - pfds)) print("AFDs ∩ pFDs =", stringify(afds & pfds)) print("1 - PerValue([DeviceId] -> Data) =", 0.1714285714) diff --git a/src/python_bindings/ac/bind_ac.cpp b/src/python_bindings/ac/bind_ac.cpp index 9255b57eb1..a3b276c292 100644 --- a/src/python_bindings/ac/bind_ac.cpp +++ b/src/python_bindings/ac/bind_ac.cpp @@ -1,4 +1,9 @@ -#include "bind_ac.h" +#include "ac/bind_ac.h" + +#include +#include +#include +#include #include #include @@ -7,9 +12,7 @@ #include "algorithms/algebraic_constraints/mining_algorithms.h" #include "py_util/bind_primitive.h" -namespace { namespace py = pybind11; -} // namespace namespace python_bindings { void BindAc(py::module_& main_module) { @@ -27,7 +30,7 @@ void BindAc(py::module_& main_module) { std::vector> res; res.reserve(ranges.ranges.size() / 2); assert(ranges.ranges.size() % 2 == 0); - for (size_t i = 0; i < ranges.ranges.size(); i += 2) { + for (std::size_t i = 0; i < ranges.ranges.size(); i += 2) { // TODO: change this once a proper conversion mechanism from // `model::INumericType` is implemented std::string l_endpoint = @@ -42,12 +45,9 @@ void BindAc(py::module_& main_module) { BindPrimitiveNoBase(ac_module, "AcAlgorithm") .def("get_ac_ranges", &ACAlgorithm::GetRangesCollections, py::return_value_policy::reference_internal) - .def( - "get_ac_exceptions", - [](ACAlgorithm& algo) { - algo.CollectACExceptions(); - return algo.GetACExceptions(); - }, - py::return_value_policy::reference_internal); + .def("get_ac_exceptions", [](ACAlgorithm& algo) { + algo.CollectACExceptions(); + return algo.GetACExceptions(); + }); } } // namespace python_bindings diff --git a/src/python_bindings/ar/bind_ar.cpp b/src/python_bindings/ar/bind_ar.cpp index b87ef805fa..3448fe618e 100644 --- a/src/python_bindings/ar/bind_ar.cpp +++ b/src/python_bindings/ar/bind_ar.cpp @@ -1,4 +1,4 @@ -#include "bind_ar.h" +#include "ar/bind_ar.h" #include #include @@ -7,9 +7,7 @@ #include "algorithms/association_rules/mining_algorithms.h" #include "py_util/bind_primitive.h" -namespace { namespace py = pybind11; -} // namespace namespace python_bindings { void BindAr(py::module_& main_module) { diff --git a/src/python_bindings/bind_main_classes.cpp b/src/python_bindings/bind_main_classes.cpp index 2f3ea88a16..948bc8a3a6 100644 --- a/src/python_bindings/bind_main_classes.cpp +++ b/src/python_bindings/bind_main_classes.cpp @@ -14,8 +14,9 @@ #include "py_util/opt_to_py.h" #include "py_util/py_to_any.h" -namespace { namespace py = pybind11; + +namespace { using algos::Algorithm; auto const kVoidIndex = std::type_index{typeid(void)}; diff --git a/src/python_bindings/data/bind_data.cpp b/src/python_bindings/data/bind_data.cpp new file mode 100644 index 0000000000..0eeea3de62 --- /dev/null +++ b/src/python_bindings/data/bind_data.cpp @@ -0,0 +1,24 @@ +#include "data/bind_data.h" + +#include +#include + +#include "config/tabular_data/input_table_type.h" +#include "model/table/column_combination.h" + +namespace py = pybind11; + +namespace python_bindings { +void BindDataModule(py::module_& main_module) { + auto data_module = main_module.def_submodule("data"); + data_module.doc() = "Contains everything related to data itself."; + auto table_tag = py::class_(data_module, "Table"); + table_tag.doc() = "Tag type for tabular data."; + + using namespace model; + py::class_(data_module, "ColumnCombination") + .def("__str__", &ColumnCombination::ToString) + .def_property_readonly("table_index", &ColumnCombination::GetTableIndex) + .def_property_readonly("column_indices", &ColumnCombination::GetColumnIndices); +} +} // namespace python_bindings diff --git a/src/python_bindings/data/bind_data.h b/src/python_bindings/data/bind_data.h new file mode 100644 index 0000000000..addc2530a3 --- /dev/null +++ b/src/python_bindings/data/bind_data.h @@ -0,0 +1,7 @@ +#pragma once + +#include + +namespace python_bindings { +void BindDataModule(pybind11::module_& main_module); +} // namespace python_bindings diff --git a/src/python_bindings/dd/bind_split.cpp b/src/python_bindings/dd/bind_split.cpp index e31846e1ce..2fe07a84ea 100644 --- a/src/python_bindings/dd/bind_split.cpp +++ b/src/python_bindings/dd/bind_split.cpp @@ -1,4 +1,4 @@ -#include "bind_split.h" +#include "dd/bind_split.h" #include #include @@ -7,9 +7,7 @@ #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) { diff --git a/src/python_bindings/fd/bind_fd.cpp b/src/python_bindings/fd/bind_fd.cpp index 726024c6a3..1f8e4740ca 100644 --- a/src/python_bindings/fd/bind_fd.cpp +++ b/src/python_bindings/fd/bind_fd.cpp @@ -1,4 +1,8 @@ -#include "bind_fd.h" +#include "fd/bind_fd.h" + +#include +#include +#include #include #include @@ -10,9 +14,9 @@ #include "py_util/bind_primitive.h" #include "util/bitset_utils.h" -namespace { namespace py = pybind11; +namespace { template py::tuple VectorToTuple(std::vector vec) { std::size_t const size = vec.size(); diff --git a/src/python_bindings/fd/bind_fd_verification.cpp b/src/python_bindings/fd/bind_fd_verification.cpp index ca65c64236..ad63e62ad2 100644 --- a/src/python_bindings/fd/bind_fd_verification.cpp +++ b/src/python_bindings/fd/bind_fd_verification.cpp @@ -1,4 +1,4 @@ -#include "bind_fd_verification.h" +#include "fd/bind_fd_verification.h" #include #include @@ -8,9 +8,7 @@ #include "algorithms/fd/verification_algorithms.h" #include "py_util/bind_primitive.h" -namespace { namespace py = pybind11; -} // namespace namespace python_bindings { void BindFdVerification(pybind11::module_& main_module) { @@ -30,6 +28,8 @@ void BindFdVerification(pybind11::module_& main_module) { .def("get_num_error_rows", &FDVerifier::GetNumErrorRows) .def("get_highlights", &FDVerifier::GetHighlights); + // Create AFD verification module alias. We currently consider FD verification and AFD + // verification to be the same. main_module.attr("afd_verification") = fd_verification_module; } } // namespace python_bindings diff --git a/src/python_bindings/gfd/bind_gfd_verification.cpp b/src/python_bindings/gfd/bind_gfd_verification.cpp index 94d91e7db8..f9deff7027 100644 --- a/src/python_bindings/gfd/bind_gfd_verification.cpp +++ b/src/python_bindings/gfd/bind_gfd_verification.cpp @@ -6,9 +6,7 @@ #include "algorithms/gfd/verification_algorithms.h" #include "py_util/bind_primitive.h" -namespace { namespace py = pybind11; -} // namespace namespace python_bindings { void BindGfdVerification(pybind11::module_& main_module) { diff --git a/src/python_bindings/mfd/bind_mfd_verification.cpp b/src/python_bindings/mfd/bind_mfd_verification.cpp index 6e7d3bfd71..007b1b7ffa 100644 --- a/src/python_bindings/mfd/bind_mfd_verification.cpp +++ b/src/python_bindings/mfd/bind_mfd_verification.cpp @@ -1,4 +1,4 @@ -#include "bind_mfd_verification.h" +#include "mfd/bind_mfd_verification.h" #include #include @@ -7,9 +7,7 @@ #include "algorithms/metric/verification_algorithms.h" #include "py_util/bind_primitive.h" -namespace { namespace py = pybind11; -} // namespace namespace python_bindings { void BindMfdVerification(py::module_& main_module) { diff --git a/src/python_bindings/py_util/bind_primitive.h b/src/python_bindings/py_util/bind_primitive.h index 819cc2343c..9ab6ea5f32 100644 --- a/src/python_bindings/py_util/bind_primitive.h +++ b/src/python_bindings/py_util/bind_primitive.h @@ -84,10 +84,10 @@ auto BindPrimitiveNoBase(pybind11::module_& module, char const* algo_name) { using algos::Algorithm; auto algos_module = module.def_submodule("algorithms"); - auto default_module = + auto default_algorithm = detail::RegisterAlgorithm(algos_module, algo_name); - algos_module.attr("Default") = default_module; - return default_module; + algos_module.attr("Default") = default_algorithm; + return default_algorithm; } } // namespace python_bindings diff --git a/src/python_bindings/py_util/opt_to_py.cpp b/src/python_bindings/py_util/opt_to_py.cpp index 71ba870752..e4bf9684b2 100644 --- a/src/python_bindings/py_util/opt_to_py.cpp +++ b/src/python_bindings/py_util/opt_to_py.cpp @@ -14,8 +14,9 @@ #include "config/max_lhs/type.h" #include "config/thread_number/type.h" -namespace { namespace py = pybind11; + +namespace { using ConvFunction = std::function; template diff --git a/src/python_bindings/py_util/py_to_any.cpp b/src/python_bindings/py_util/py_to_any.cpp index d8eb12e923..bff6fee8e3 100644 --- a/src/python_bindings/py_util/py_to_any.cpp +++ b/src/python_bindings/py_util/py_to_any.cpp @@ -19,9 +19,9 @@ #include "py_util/create_dataframe_reader.h" #include "util/enum_to_available_values.h" -namespace { - namespace py = pybind11; + +namespace { using ConvFunc = std::function; template diff --git a/src/python_bindings/statistics/bind_statistics.cpp b/src/python_bindings/statistics/bind_statistics.cpp index 5a23403be0..f5d2f66969 100644 --- a/src/python_bindings/statistics/bind_statistics.cpp +++ b/src/python_bindings/statistics/bind_statistics.cpp @@ -1,4 +1,4 @@ -#include "bind_statistics.h" +#include "statistics/bind_statistics.h" #include #include @@ -6,9 +6,7 @@ #include "algorithms/statistics/data_stats.h" #include "py_util/bind_primitive.h" -namespace { namespace py = pybind11; -} // namespace namespace PYBIND11_NAMESPACE { namespace detail { diff --git a/src/python_bindings/ucc/bind_ucc.cpp b/src/python_bindings/ucc/bind_ucc.cpp index f565f24b52..50b2b90379 100644 --- a/src/python_bindings/ucc/bind_ucc.cpp +++ b/src/python_bindings/ucc/bind_ucc.cpp @@ -1,4 +1,4 @@ -#include "bind_ucc.h" +#include "ucc/bind_ucc.h" #include #include @@ -9,10 +9,8 @@ #include "py_util/bind_primitive.h" #include "util/bitset_utils.h" -namespace { namespace py = pybind11; using model::UCC; -} // namespace namespace python_bindings { void BindUcc(py::module_& main_module) { diff --git a/src/python_bindings/ucc/bind_ucc_verification.cpp b/src/python_bindings/ucc/bind_ucc_verification.cpp index e7e8646a7a..95013f2dbc 100644 --- a/src/python_bindings/ucc/bind_ucc_verification.cpp +++ b/src/python_bindings/ucc/bind_ucc_verification.cpp @@ -1,4 +1,4 @@ -#include "bind_ucc_verification.h" +#include "ucc/bind_ucc_verification.h" #include #include @@ -6,9 +6,7 @@ #include "algorithms/ucc/verification_algorithms.h" #include "py_util/bind_primitive.h" -namespace { namespace py = pybind11; -} // namespace namespace python_bindings { void BindUccVerification(pybind11::module_& main_module) { @@ -22,6 +20,8 @@ void BindUccVerification(pybind11::module_& main_module) { .def("get_num_rows_violating_ucc", &UCCVerifier::GetNumRowsViolatingUCC) .def("get_clusters_violating_ucc", &UCCVerifier::GetClustersViolatingUCC) .def("get_error", &UCCVerifier::GetError); + // Create AUCC verification module alias. We currently consider UCC verification and AUCC + // verification to be the same. main_module.attr("aucc_verification") = ucc_verification_module; } } // namespace python_bindings