LCOV - code coverage report
Current view: top level - python - slice_utils.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 11 11 100.0 %
Date: 2024-11-24 01:48:31 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // SPDX-License-Identifier: BSD-3-Clause
       2             : // Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
       3             : #include "pybind11.h"
       4             : 
       5             : #include "scipp/variable/variable.h"
       6             : 
       7             : namespace py = pybind11;
       8             : using namespace scipp;
       9             : using namespace scipp::variable;
      10             : 
      11             : std::tuple<Variable, Variable>
      12        2486 : label_bounds_from_pyslice(const py::slice &py_slice) {
      13        2486 :   auto start = py::getattr(py_slice, "start");
      14        2486 :   auto stop = py::getattr(py_slice, "stop");
      15        2486 :   auto step = py::getattr(py_slice, "step");
      16        2486 :   auto start_var = start.is_none() ? Variable{} : start.cast<Variable>();
      17        1149 :   auto stop_var = stop.is_none() ? Variable{} : stop.cast<Variable>();
      18          97 :   if (!step.is_none()) {
      19           1 :     throw std::runtime_error(
      20           2 :         "Step cannot be specified for value based slicing.");
      21             :   }
      22         192 :   return std::tuple{start_var, stop_var};
      23        8320 : }

Generated by: LCOV version 1.14