LCOV - code coverage report
Current view: top level - variable - bin_util.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 12 12 100.0 %
Date: 2024-11-17 01:47:58 Functions: 3 3 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_util.h"
       6             : 
       7             : namespace scipp::variable {
       8             : 
       9             : namespace {
      10         918 : void check_edges(const Variable &edges, const Dim dim) {
      11         918 :   if (edges.dims()[dim] < 2)
      12           4 :     throw except::BinEdgeError("Invalid bin edges: less than 2 values");
      13         914 : }
      14             : } // namespace
      15             : 
      16             : /// Return view onto left bin edges, i.e., all but the last edge
      17         459 : Variable left_edge(const Variable &edges) {
      18         459 :   const auto dim = edges.dims().inner();
      19         459 :   check_edges(edges, dim);
      20         457 :   return edges.slice({dim, 0, edges.dims()[dim] - 1});
      21             : }
      22             : 
      23             : /// Return view onto right bin edges, i.e., all but the first edge
      24         459 : Variable right_edge(const Variable &edges) {
      25         459 :   const auto dim = edges.dims().inner();
      26         459 :   check_edges(edges, dim);
      27         457 :   return edges.slice({dim, 1, edges.dims()[dim]});
      28             : }
      29             : 
      30             : } // namespace scipp::variable

Generated by: LCOV version 1.14