ardupilot/Tools/LogAnalyzer/tests/TestNaN.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.3 KiB
Python
Raw Normal View History

# AP_FLAKE8_CLEAN
2017-03-20 19:38:21 -03:00
import math
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
nans_ok = {
"CTUN": ["DSAlt", "TAlt"],
"POS": ["RelOriginAlt"],
}
2017-03-20 19:38:21 -03:00
for channel in logdata.channels.keys():
for field in logdata.channels[channel].keys():
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()
self.result.statusMessage += "Found NaN in %s.%s\n" % (
channel,
field,
)
2017-03-20 19:38:21 -03:00
raise ValueError()
except ValueError:
2017-03-20 19:38:21 -03:00
continue