LCOV - code coverage report
Current view: top level - python - geometry.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 7 14 50.0 %
Date: 2024-04-28 01:25:40 Functions: 2 3 66.7 %

          Line data    Source code
       1             : // SPDX-License-Identifier: BSD-3-Clause
       2             : // Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
       3             : /// @file
       4             : /// @author Simon Heybrock
       5             : #include <Eigen/Geometry>
       6             : 
       7             : #include "scipp/variable/misc_operations.h"
       8             : 
       9             : #include "docstring.h"
      10             : #include "pybind11.h"
      11             : 
      12             : using namespace scipp;
      13             : using namespace scipp::variable::geometry;
      14             : 
      15             : namespace py = pybind11;
      16             : 
      17           3 : void init_geometry(py::module &m) {
      18           3 :   auto geom_m = m.def_submodule("geometry");
      19             : 
      20           3 :   geom_m.def(
      21             :       "as_vectors",
      22          10 :       [](const Variable &x, const Variable &y, const Variable &z) {
      23          10 :         return position(x, y, z);
      24             :       },
      25           0 :       py::arg("x"), py::arg("y"), py::arg("z"),
      26           0 :       py::call_guard<py::gil_scoped_release>());
      27             : 
      28           3 :   geom_m.def(
      29           0 :       "rotation_matrix_from_quaternion_coeffs", [](py::array_t<double> value) {
      30           0 :         if (value.size() != 4)
      31           0 :           throw std::runtime_error("Incompatible list size: expected size 4.");
      32           0 :         return Eigen::Quaterniond(value.cast<std::vector<double>>().data())
      33           0 :             .toRotationMatrix();
      34             :       });
      35           3 : }

Generated by: LCOV version 1.14