Skip to content
Snippets Groups Projects
Commit fa52eab5 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Use adaptive scaling to distinguish between warnings and errors

parent 4a1bf74b
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,7 @@ from math import log10 ...@@ -24,7 +24,7 @@ from math import log10
from sys import argv from sys import argv
## \cond ## \cond
number_reg = re.compile(r'-?[0-9]\.[0-9]+E[-+][0-9]{2,2}') number_reg = re.compile(r'-?[0-9]\.[0-9]+E?[-+][0-9]{2,5}')
## \endcond ## \endcond
## \brief Main execution code ## \brief Main execution code
...@@ -291,6 +291,18 @@ def mismatch_severities(str_f_values, str_c_values, config): ...@@ -291,6 +291,18 @@ def mismatch_severities(str_f_values, str_c_values, config):
result = [0 for ri in range(len(str_f_values))] result = [0 for ri in range(len(str_f_values))]
for i in range(len(str_f_values)): for i in range(len(str_f_values)):
if (str_f_values[i] != str_c_values[i]): if (str_f_values[i] != str_c_values[i]):
# Add the exponent marker if it is missing
temp_str_value = str_f_values[i][1:]
split_temp = temp_str_value.split('-')
if len(split_temp) > 1:
if (split_temp[0][-1] != 'E'):
str_f_values[i] = str_f_values[i][0] + split_temp[0] + "E-" + split_temp[1]
temp_str_value = str_c_values[i][1:]
split_temp = temp_str_value.split('-')
if len(split_temp) > 1:
if (split_temp[0][-1] != 'E'):
str_c_values[i] = str_c_values[i][0] + split_temp[0] + "E-" + split_temp[1]
# End of missing exponent marker correction
f_values = [float(str_f_values[j]) for j in range(len(str_f_values))] f_values = [float(str_f_values[j]) for j in range(len(str_f_values))]
c_values = [float(str_c_values[j]) for j in range(len(str_c_values))] c_values = [float(str_c_values[j]) for j in range(len(str_c_values))]
if (len(f_values) != len(c_values)): return [] if (len(f_values) != len(c_values)): return []
...@@ -298,22 +310,27 @@ def mismatch_severities(str_f_values, str_c_values, config): ...@@ -298,22 +310,27 @@ def mismatch_severities(str_f_values, str_c_values, config):
c_log_values = [0.0 for j in range(len(c_values))] c_log_values = [0.0 for j in range(len(c_values))]
max_f_log = -1.0e12 max_f_log = -1.0e12
max_c_log = -1.0e12 max_c_log = -1.0e12
min_f_log = 1.0e12
min_c_log = 1.0e12
for j in range(len(f_values)) : for j in range(len(f_values)) :
if f_values[j] < 0.0: f_values[j] *= -1.0 if f_values[j] < 0.0: f_values[j] *= -1.0
if c_values[j] < 0.0: c_values[j] *= -1.0 if c_values[j] < 0.0: c_values[j] *= -1.0
f_log_values[j] = log10(f_values[j]) if f_values[j] > 0.0 else -999 f_log_values[j] = log10(f_values[j]) if f_values[j] > 0.0 else -999
c_log_values[j] = log10(c_values[j]) if c_values[j] > 0.0 else -999 c_log_values[j] = log10(c_values[j]) if c_values[j] > 0.0 else -999
if (f_log_values[j] > max_f_log): max_f_log = f_log_values[j] if (f_log_values[j] > max_f_log): max_f_log = f_log_values[j]
if (c_log_values[j] > max_c_log): max_c_log = f_log_values[j] if (c_log_values[j] > max_c_log): max_c_log = c_log_values[j]
if (f_log_values[j] < min_f_log): min_f_log = f_log_values[j]
if (c_log_values[j] < min_c_log): min_c_log = c_log_values[j]
if (c_log_values[i] < max_c_log - 5.0 and f_log_values[i] < max_f_log - 5.0): if (c_log_values[i] < max_c_log - 5.0 and f_log_values[i] < max_f_log - 5.0):
result[i] = 1 result[i] = 1
else: else:
warning_scale = 10.0**(int(max_f_log - f_log_values[i]))
difference = c_values[i] - f_values[i] difference = c_values[i] - f_values[i]
fractional = 1.0 fractional = 1.0
if (f_values[i] != 0.0): if (f_values[i] != 0.0):
fractional = difference / f_values[i] fractional = difference / f_values[i]
if (fractional < 0.0): fractional *= -1.0 if (fractional < 0.0): fractional *= -1.0
if (fractional < config['warning_threshold']): result[i] = 2 if (fractional < warning_scale * config['warning_threshold']): result[i] = 2
else: result[i] = 3 else: result[i] = 3
return result return result
......
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