metric_average.h
Go to the documentation of this file.
1 
8 #pragma once
9 #include "interop/util/math.h"
10 
11 namespace illumina { namespace interop { namespace model { namespace summary
12 {
14  class metric_average // TODO: Use this everywhere to clean up summary logic!
15  {
16  public:
18  metric_average() : m_sum(0), m_count(0){}
19 
20  public:
26  metric_average& operator+=(const float val)
27  {
28  if(!std::isnan(val))
29  {
30  m_sum += val;
31  m_count += 1;
32  }
33  return *this;
34  }
39  operator float()const
40  {
41  return average();
42  }
47  float average()const
48  {
49  if(m_count == 0) return std::numeric_limits<float>::quiet_NaN();
50  return m_sum / static_cast<float>(m_count);
51  }
52 
53  private:
54  float m_sum;
55  size_t m_count;
56  };
57 
58 
59 }}}}
60 
Definition: enum_description.h:15
def summary(run_metrics, level='Total', columns=None, dtype='f4', ignore_missing_columns=True, extra)
Definition: core.py:217
metric_average()
Definition: metric_average.h:18
float average() const
Definition: metric_average.h:47
metric_average & operator+=(const float val)
Definition: metric_average.h:26