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

          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 "scipp/variable/bin_array_variable.tcc"
       6             : 
       7             : namespace scipp::variable::bin_array_variable_detail {
       8             : 
       9       15434 : std::tuple<Variable, scipp::index> contiguous_indices(const Variable &parent,
      10             :                                                       const Dimensions &dims) {
      11       15434 :   auto indices = Variable(parent, dims);
      12       15434 :   copy(parent, indices);
      13       15434 :   scipp::index size = 0;
      14      166223 :   for (auto &range : indices.values<scipp::index_pair>().as_span()) {
      15      150789 :     range.second += size - range.first;
      16      150789 :     range.first = size;
      17      150789 :     size = range.second;
      18             :   }
      19       30868 :   return std::tuple{indices, size};
      20       15434 : }
      21             : 
      22      185364 : const scipp::index_pair *index_pair_data(const Variable &indices) {
      23      185364 :   return indices.template values<scipp::index_pair>().data();
      24             : }
      25             : 
      26        4647 : scipp::index size_from_end_index(const Variable &end) {
      27        9294 :   return end.dims().volume() > 0 ? end.values<scipp::index>().as_span().back()
      28        9294 :                                  : 0;
      29             : }
      30             : 
      31           4 : VariableConceptHandle zero_indices(const scipp::index size) {
      32           8 :   return makeVariable<scipp::index_pair>(Dims{Dim::X}, Shape{size})
      33           8 :       .data_handle();
      34             : }
      35             : 
      36             : } // namespace scipp::variable::bin_array_variable_detail

Generated by: LCOV version 1.14