Commit 6eccb446 authored by Kirill Smelkov's avatar Kirill Smelkov

kpi: Fix Σqci and Σcause when invoked on NA data

There was a thinko that led to returning 0 instead of NA when there are
not .QCI or .CAUSE fields except .sum . Without added fix, e.g.

	Σqci(Measurement(), 'ERAB.EstabInitAttNbr.QCI')

was returning 0 instead of NA.

-> Fix it.
parent 762153ab
...@@ -602,7 +602,7 @@ def _Σx(m: Measurement, name_x: str, _all_x: func): ...@@ -602,7 +602,7 @@ def _Σx(m: Measurement, name_x: str, _all_x: func):
if not isNA(s): if not isNA(s):
return s return s
s = s.dtype.type(0) s = s.dtype.type(0)
ok = True ok = True if len(name_xv) > 0 else False
for _ in name_xv: for _ in name_xv:
v = m[_] v = m[_]
# we don't know the answer even if single value is NA # we don't know the answer even if single value is NA
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
# See COPYING file for full licensing terms. # See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options. # See https://www.nexedi.com/licensing for rationale and options.
from xlte.kpi import Calc, MeasurementLog, Measurement, Interval, NA, isNA from xlte.kpi import Calc, MeasurementLog, Measurement, Interval, NA, isNA, Σqci, Σcause
import numpy as np import numpy as np
from pytest import raises from pytest import raises
...@@ -420,6 +420,34 @@ def test_Calc_erab_accessibility(): ...@@ -420,6 +420,34 @@ def test_Calc_erab_accessibility():
_(InititialEPSBEstabSR, 100 * 2*3*4 / (7*8*9)) _(InititialEPSBEstabSR, 100 * 2*3*4 / (7*8*9))
# verify Σqci.
def test_Σqci():
m = Measurement()
x = 'ERAB.EstabInitAttNbr'
def Σ():
return Σqci(m, x+'.QCI')
assert isNA(Σ())
m[x+'.sum'] = 123
assert Σ() == 123
# TODO sum over individual causes (when implemented)
# verify Σcause.
def test_Σcause():
m = Measurement()
x = 'RRC.ConnEstabAtt'
def Σ():
return Σcause(m, x+'.CAUSE')
assert isNA(Σ())
m[x+'.sum'] = 123
assert Σ() == 123
# TODO sum over individual causes (when implemented)
def test_NA(): def test_NA():
def _(typ): def _(typ):
na = NA(typ(0).dtype) na = NA(typ(0).dtype)
......
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