Skip to content
Snippets Groups Projects
Commit 57ee0633 authored by Timo Koch's avatar Timo Koch
Browse files

[bin][fuzzycompare] Test for NaN and inf

parent dbc7bb01
No related branches found
No related tags found
1 merge request!617[WIP] Next
......@@ -12,6 +12,7 @@ import xml.etree.ElementTree as ET
from operator import attrgetter, itemgetter
import json
import sys
import math
from six.moves import range
from six.moves import zip
......@@ -142,6 +143,15 @@ def is_fuzzy_equal_text(text1, text2, parameter, numComp, absolute, relative, ze
floatList1 = [float(i) for i in list1]
floatList2 = [float(i) for i in list2]
# check for nan and inf
for number1, number2 in zip(floatList1, floatList2):
if math.isnan(number1) or math.isnan(number2):
print('Parameter {} contains NaN!'.format(parameter))
return False
if math.isinf(number1) or math.isinf(number2):
print('Parameter {} contains inf!'.format(parameter))
return False
# manipulate the data set for the sake of sensible comparison
# if the parameter is listed in the zeroThreshold dictionary replace all float under threshold with zero.
# only replace them with zero if the parameters in both lists are under the threshold. Otherwise we
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment