From 6796b4a29a4dd35e1f318f9bdeef3cefe518770d Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 7 Jun 2022 08:58:59 +0300 Subject: [PATCH] [#227] netmap: Remove unused aggregators and normalizers Signed-off-by: Leonard Lyubich --- netmap/aggregator.go | 56 -------------------------------------------- 1 file changed, 56 deletions(-) diff --git a/netmap/aggregator.go b/netmap/aggregator.go index ed6bffee..e7095119 100644 --- a/netmap/aggregator.go +++ b/netmap/aggregator.go @@ -17,11 +17,6 @@ type ( Normalize(w float64) float64 } - meanSumAgg struct { - sum float64 - count int - } - meanAgg struct { mean float64 count int @@ -31,10 +26,6 @@ type ( min float64 } - maxAgg struct { - max float64 - } - meanIQRAgg struct { k float64 arr []float64 @@ -44,33 +35,21 @@ type ( min float64 } - maxNorm struct { - max float64 - } - sigmoidNorm struct { scale float64 } - constNorm struct { - value float64 - } - // weightFunc calculates n's weight. weightFunc = func(NodeInfo) float64 ) var ( - _ aggregator = (*meanSumAgg)(nil) _ aggregator = (*meanAgg)(nil) _ aggregator = (*minAgg)(nil) - _ aggregator = (*maxAgg)(nil) _ aggregator = (*meanIQRAgg)(nil) _ normalizer = (*reverseMinNorm)(nil) - _ normalizer = (*maxNorm)(nil) _ normalizer = (*sigmoidNorm)(nil) - _ normalizer = (*constNorm)(nil) ) // newWeightFunc returns weightFunc which multiplies normalized @@ -112,19 +91,6 @@ func newSigmoidNorm(scale float64) normalizer { return &sigmoidNorm{scale: scale} } -func (a *meanSumAgg) Add(n float64) { - a.sum += n - a.count++ -} - -func (a *meanSumAgg) Compute() float64 { - if a.count == 0 { - return 0 - } - - return a.sum / float64(a.count) -} - func (a *meanAgg) Add(n float64) { c := a.count + 1 a.mean = a.mean*(float64(a.count)/float64(c)) + n/float64(c) @@ -145,16 +111,6 @@ func (a *minAgg) Compute() float64 { return a.min } -func (a *maxAgg) Add(n float64) { - if n > a.max { - a.max = n - } -} - -func (a *maxAgg) Compute() float64 { - return a.max -} - func (a *meanIQRAgg) Add(n float64) { a.arr = append(a.arr, n) } @@ -200,14 +156,6 @@ func (r *reverseMinNorm) Normalize(w float64) float64 { return r.min / w } -func (r *maxNorm) Normalize(w float64) float64 { - if r.max == 0 { - return 0 - } - - return w / r.max -} - func (r *sigmoidNorm) Normalize(w float64) float64 { if r.scale == 0 { return 0 @@ -217,7 +165,3 @@ func (r *sigmoidNorm) Normalize(w float64) float64 { return x / (1 + x) } - -func (r *constNorm) Normalize(_ float64) float64 { - return r.value -}