2022-07-18 10:52:56 -03:00
|
|
|
# AP_FLAKE8_CLEAN
|
|
|
|
|
|
|
|
|
2017-03-20 19:38:21 -03:00
|
|
|
import math
|
|
|
|
|
2022-07-18 11:09:04 -03:00
|
|
|
from LogAnalyzer import Test, TestResult
|
|
|
|
|
|
|
|
|
2017-03-20 19:38:21 -03:00
|
|
|
class TestNaN(Test):
|
|
|
|
'''test for NaNs present in log'''
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
Test.__init__(self)
|
|
|
|
self.name = "NaNs"
|
|
|
|
|
|
|
|
def run(self, logdata, verbose):
|
|
|
|
self.result = TestResult()
|
|
|
|
self.result.status = TestResult.StatusType.GOOD
|
|
|
|
|
|
|
|
def FAIL():
|
|
|
|
self.result.status = TestResult.StatusType.FAIL
|
|
|
|
|
2018-11-28 17:35:39 -04:00
|
|
|
nans_ok = {
|
2022-07-18 11:09:04 -03:00
|
|
|
"CTUN": ["DSAlt", "TAlt"],
|
|
|
|
"POS": ["RelOriginAlt"],
|
2018-11-28 17:35:39 -04:00
|
|
|
}
|
2017-03-20 19:38:21 -03:00
|
|
|
|
|
|
|
for channel in logdata.channels.keys():
|
|
|
|
for field in logdata.channels[channel].keys():
|
2018-11-28 17:35:39 -04:00
|
|
|
if channel in nans_ok and field in nans_ok[channel]:
|
|
|
|
continue
|
2017-03-20 19:38:21 -03:00
|
|
|
try:
|
|
|
|
for tupe in logdata.channels[channel][field].listData:
|
|
|
|
(ts, val) = tupe
|
|
|
|
if isinstance(val, float) and math.isnan(val):
|
|
|
|
FAIL()
|
2022-07-18 11:09:04 -03:00
|
|
|
self.result.statusMessage += "Found NaN in %s.%s\n" % (
|
|
|
|
channel,
|
|
|
|
field,
|
|
|
|
)
|
2017-03-20 19:38:21 -03:00
|
|
|
raise ValueError()
|
2022-07-18 10:52:56 -03:00
|
|
|
except ValueError:
|
2017-03-20 19:38:21 -03:00
|
|
|
continue
|