From dfb3a8da055cf75daf8f08e9c05efbf2acda2425 Mon Sep 17 00:00:00 2001 From: Marcel Walter Date: Tue, 21 Nov 2023 10:49:13 +0100 Subject: [PATCH] :sparkles: Added detect_bdl_pairs to pyfiction --- .../simulation/sidb/detect_bdl_pairs.hpp | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/detect_bdl_pairs.hpp diff --git a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/detect_bdl_pairs.hpp b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/detect_bdl_pairs.hpp new file mode 100644 index 000000000..993f7e0d0 --- /dev/null +++ b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/detect_bdl_pairs.hpp @@ -0,0 +1,62 @@ +// +// Created by marcel on 21.11.23. +// + +#ifndef PYFICTION_DETECT_BDL_PAIRS_HPP +#define PYFICTION_DETECT_BDL_PAIRS_HPP + +#include "pyfiction/documentation.hpp" +#include "pyfiction/types.hpp" + +#include + +#include +#include + +namespace pyfiction +{ + +namespace detail +{ + +template +void detect_bdl_pairs(pybind11::module& m) +{ + namespace py = pybind11; + using namespace pybind11::literals; + + py::class_>(m, "bdl_pair", DOC(fiction_bdl_pair)) + .def(py::init<>(), DOC(fiction_bdl_pair_bdl_pair)) + .def(py::init, fiction::cell>(), "t"_a, "u"_a, + "l"_a, DOC(fiction_bdl_pair_bdl_pair_2)) + .def_readonly("type", &fiction::bdl_pair::type, DOC(fiction_bdl_pair_type)) + .def_readonly("upper", &fiction::bdl_pair::upper, DOC(fiction_bdl_pair_upper)) + .def_readonly("lower", &fiction::bdl_pair::lower, DOC(fiction_bdl_pair_lower)) + + ; + + m.def("detect_bdl_pairs", &fiction::detect_bdl_pairs, "lyt"_a, "type"_a, + "params"_a = fiction::detect_bdl_pairs_params{}, DOC(fiction_detect_bdl_pairs)); +} + +} // namespace detail + +inline void detect_bdl_pairs(pybind11::module& m) +{ + namespace py = pybind11; + + py::class_(m, "detect_bdl_pairs_params", DOC(fiction_detect_bdl_pairs_params)) + .def(py::init<>()) + .def_readwrite("minimum_distance", &fiction::detect_bdl_pairs_params::minimum_distance, + DOC(fiction_detect_bdl_pairs_params_minimum_distance)) + .def_readwrite("maximum_distance", &fiction::detect_bdl_pairs_params::maximum_distance, + DOC(fiction_detect_bdl_pairs_params_maximum_distance)); + + // NOTE be careful with the order of the following calls! Python will resolve the first matching overload! + + detail::detect_bdl_pairs(m); +} + +} // namespace pyfiction + +#endif // PYFICTION_DETECT_BDL_PAIRS_HPP