LCOV - code coverage report
Current view: top level - bindings/interfaces - TransformationBuilderInterface.py.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 33 33 100.0 %
Date: 2025-04-29 15:56:08 Functions: 8 8 100.0 %

          Line data    Source code
       1             : // SPDX-FileCopyrightText: 2024 Pairinteraction Developers
       2             : // SPDX-License-Identifier: LGPL-3.0-or-later
       3             : 
       4             : #include "./TransformationBuilderInterface.py.hpp"
       5             : 
       6             : #include "pairinteraction/interfaces/TransformationBuilderInterface.hpp"
       7             : 
       8             : #include <nanobind/eigen/dense.h>
       9             : #include <nanobind/eigen/sparse.h>
      10             : #include <nanobind/nanobind.h>
      11             : #include <nanobind/stl/array.h>
      12             : #include <nanobind/stl/complex.h>
      13             : #include <nanobind/stl/vector.h>
      14             : 
      15             : namespace nb = nanobind;
      16             : using namespace nb::literals;
      17             : using namespace pairinteraction;
      18             : 
      19             : template <typename T>
      20           2 : static void declare_transformation(nb::module_ &m, std::string const &type_name) {
      21           2 :     std::string pyclass_name = "Transformation" + type_name;
      22           4 :     nb::class_<Transformation<T>> pyclass(m, pyclass_name.c_str());
      23           2 :     pyclass.def(nb::init<>())
      24           2 :         .def_rw("matrix", &Transformation<T>::matrix)
      25             :         .def_rw("transformation_type", &Transformation<T>::transformation_type);
      26           2 : }
      27             : 
      28           1 : static void declare_sorting(nb::module_ &m) {
      29           1 :     nb::class_<Sorting> pyclass(m, "Sorting");
      30           1 :     pyclass.def(nb::init<>())
      31           1 :         .def_rw("matrix", &Sorting::matrix)
      32             :         .def_rw("transformation_type", &Sorting::transformation_type);
      33           1 : }
      34             : 
      35           1 : static void declare_indices_of_blocks(nb::module_ &m) {
      36           1 :     nb::class_<IndicesOfBlock> pyclass(m, "IndicesOfBlock");
      37           2 :     pyclass.def(nb::init<size_t, size_t>(), "start"_a, "end"_a)
      38           1 :         .def_rw("start", &IndicesOfBlock::start)
      39             :         .def_rw("end", &IndicesOfBlock::end);
      40           1 : }
      41             : 
      42           1 : static void declare_indices_of_blocks_creator(nb::module_ &m) {
      43           1 :     nb::class_<IndicesOfBlocksCreator> pyclass(m, "IndicesOfBlocksCreator");
      44           1 : }
      45             : 
      46             : template <typename T>
      47           2 : static void declare_transformation_builder_interface(nb::module_ &m, std::string const &type_name) {
      48           2 :     std::string pyclass_name = "TransformationBuilderInterface" + type_name;
      49             :     using real_t = typename TransformationBuilderInterface<T>::real_t;
      50           2 :     nb::class_<TransformationBuilderInterface<T>> pyclass(m, pyclass_name.c_str());
      51             :     pyclass.def("get_rotator",
      52           2 :                 nb::overload_cast<const std::array<real_t, 3> &, const std::array<real_t, 3> &>(
      53             :                     &TransformationBuilderInterface<T>::get_rotator, nb::const_));
      54           2 : }
      55             : 
      56           1 : void bind_transformation_builder_interface(nb::module_ &m) {
      57           1 :     declare_transformation<double>(m, "Real");
      58           1 :     declare_transformation<std::complex<double>>(m, "Complex");
      59           1 :     declare_sorting(m);
      60           1 :     declare_indices_of_blocks(m);
      61           1 :     declare_indices_of_blocks_creator(m);
      62           1 :     declare_transformation_builder_interface<double>(m, "Real");
      63           1 :     declare_transformation_builder_interface<std::complex<double>>(m, "Complex");
      64           1 : }

Generated by: LCOV version 1.16