LCOV - code coverage report
Current view: top level - dataset - bins_util.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 12 12 100.0 %
Date: 2024-04-28 01:25:40 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             : /// @file
       4             : /// @author Simon Heybrock
       5             : #pragma once
       6             : 
       7             : #include "scipp/dataset/bins.h"
       8             : #include "scipp/variable/shape.h"
       9             : #include "scipp/variable/util.h"
      10             : 
      11             : namespace scipp::dataset {
      12             : 
      13             : template <class Masks>
      14        2385 : Variable hide_masked(const Variable &data, const Masks &masks,
      15             :                      const scipp::span<const Dim> dims) {
      16        2385 :   const auto empty_range = makeVariable<scipp::index_pair>(
      17        2385 :       Values{std::pair<scipp::index, scipp::index>(0, 0)});
      18        2385 :   const auto &[begin_end, buffer_dim, buffer] = data.constituents<DataArray>();
      19        2385 :   auto indices = begin_end;
      20        8415 :   for (const auto dim : dims) {
      21        6030 :     auto mask = irreducible_mask(masks, dim);
      22        6030 :     if (mask.is_valid()) {
      23          26 :       mask = transpose(mask, intersection(data.dims(), mask.dims()).labels());
      24          26 :       indices = where(mask, empty_range, indices);
      25             :     }
      26             :   }
      27        4770 :   return make_bins_no_validate(indices, buffer_dim, buffer);
      28        2385 : }
      29             : 
      30             : } // namespace scipp::dataset

Generated by: LCOV version 1.14