Commit 43250935 authored by Kirill Smelkov's avatar Kirill Smelkov

kpi: Rename Calc.sum -> Calc.aggregate

In bf96c767 (kpi: Add way to compute aggregated counters + showcase
this) I added Calc.sum with the idea that aggregating measurements is
summing their values. That is indeed true for cumulative counters, but
to aggregate e.g. average values of something, one needs to use
different formula than simple summation. For this reason it is generally
more correct to name the aggregation method as "aggregate" instead of
"sum".

-> Do this renaming.
parent 7164e99c
......@@ -355,7 +355,7 @@
"source": [
"Let's now look at <u>raw counters</u>.\n",
"\n",
"Each Measurement comes with counters measured during particular interval. To get total values we need to aggregate them throughout all observation time via `Calc.sum`. Let's use already-loaded MeasurementLog data to showcase this:"
"Each Measurement comes with counters measured during particular interval. To get total values we need to aggregate them throughout all observation time via `Calc.aggregate`. Let's use already-loaded MeasurementLog data to showcase this:"
]
},
{
......@@ -371,7 +371,7 @@
"mhead = mlog.data()[0]\n",
"mtail = mlog.data()[-1]\n",
"calc_total = kpi.Calc(mlog, mhead['X.Tstart'], mtail['X.Tstart']+mtail['X.δT'])\n",
"Σ = calc_total.sum()"
"Σ = calc_total.aggregate()"
]
},
{
......
......@@ -136,7 +136,7 @@ def main():
mhead = mlog.data()[0]
mtail = mlog.data()[-1]
calc_total = kpi.Calc(mlog, mhead['X.Tstart'], mtail['X.Tstart']+mtail['X.δT'])
Σ = calc_total.sum()
Σ = calc_total.aggregate()
print_ΣMeasurement(Σ)
......
......@@ -21,7 +21,7 @@
- Calc is KPI calculator. It can be instantiated on MeasurementLog and time
interval over which to perform computations. Use Calc methods such as
.erab_accessibility() and .eutran_ip_throughput() to compute KPIs, and .sum()
.erab_accessibility() and .eutran_ip_throughput() to compute KPIs, and .aggregate()
to compute aggregated measurements.
- MeasurementLog maintains journal with result of measurements. Use .append()
......@@ -54,6 +54,8 @@ from __future__ import print_function, division, absolute_import
import numpy as np
from golang import func
import warnings
# Calc provides way to compute KPIs over given measurement data and time interval.
#
......@@ -71,7 +73,7 @@ from golang import func
# ──────|─────|────[────|────)──────|──────|────────>
# ←─ τ_lo τ_hi ──→ time
#
# It is also possible to merely aggregate measured values via .sum() .
# It is also possible to merely aggregate measured values via .aggregate() .
#
# See also: MeasurementLog, Measurement, ΣMeasurement.
class Calc:
......@@ -224,7 +226,7 @@ class Interval(np.void):
# It is similar to Measurement, but each value comes accompanied with
# information about how much time there was no data for that field:
#
# Σ[f].value = Σ Mi[f] if Mi[f] ≠ NA
# Σ[f].value = Aggregate Mi[f] if Mi[f] ≠ NA
# i
#
# Σ[f].τ_na = Σ Mi[X.δT] if Mi[f] = NA
......@@ -696,10 +698,10 @@ def eutran_ip_throughput(calc): # -> IPThp[QCI][dl,ul]
return thp
# sum aggregates values of all Measurements in covered time interval.
# aggregate aggregates values of all Measurements in covered time interval.
# TODO tests
@func(Calc)
def sum(calc): # -> ΣMeasurement
def aggregate(calc): # -> ΣMeasurement
Σ = ΣMeasurement()
Σ['X.Tstart'] = calc.τ_lo
Σ['X.δT'] = calc.τ_hi - calc.τ_lo
......@@ -722,6 +724,12 @@ def sum(calc): # -> ΣMeasurement
return Σ
# sum is deprecated alias to aggregate.
@func(Calc)
def sum(calc):
warnings.warn("Calc.sum is deprecated -> use Calc.aggregate instead", DeprecationWarning, stacklevel=4)
return calc.aggregate()
# _miter iterates through [.τ_lo, .τ_hi) yielding Measurements.
#
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment