LCOV - code coverage report
Current view: top level - dataset - nanmean.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 8 8 100.0 %
Date: 2024-11-24 01:48:31 Functions: 7 7 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/dataset/nanmean.h"
       6             : 
       7             : #include "scipp/dataset/astype.h"
       8             : #include "scipp/dataset/math.h" // needed by operations_common.h
       9             : #include "scipp/dataset/nansum.h"
      10             : #include "scipp/dataset/special_values.h"
      11             : #include "scipp/dataset/sum.h"
      12             : 
      13             : #include "../variable/operations_common.h"
      14             : #include "dataset_operations_common.h"
      15             : 
      16             : namespace scipp::dataset {
      17             : 
      18          37 : DataArray nanmean(const DataArray &a, const Dim dim) {
      19             :   return apply_to_data_and_drop_dim(
      20          74 :       a, [](auto &&..._) { return nanmean(_...); }, dim, a.masks());
      21             : }
      22             : 
      23          25 : DataArray nanmean(const DataArray &a) {
      24          50 :   return variable::normalize_impl(nansum(a), sum(isfinite(a)));
      25             : }
      26             : 
      27          15 : Dataset nanmean(const Dataset &d, const Dim dim) {
      28          30 :   return apply_to_items(d, [](auto &&..._) { return nanmean(_...); }, dim);
      29             : }
      30             : 
      31           6 : Dataset nanmean(const Dataset &d) {
      32          12 :   return apply_to_items(d, [](auto &&..._) { return nanmean(_...); });
      33             : }
      34             : } // namespace scipp::dataset

Generated by: LCOV version 1.14