Loading src/scripts/pycompare.py +55 −32 Original line number Diff line number Diff line Loading @@ -230,7 +230,7 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=4, log_file=None): if (len(severities) > 0): if (severities[-1] == 0): log_line = ( log_line + c_groups[-1] + c_line[c_ends[-1]:len(c_line) - 2] log_line + c_groups[-1] + c_line[c_ends[-1]:len(c_line) - 1] ) elif (severities[-1] == 1): log_line = ( Loading Loading @@ -291,50 +291,73 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=4, log_file=None): # \returns result: `array(int)` An array of severity codes ordered as the # input numeric values. def mismatch_severities(str_f_values, str_c_values, config): result = [] if len(str_f_values) == len(str_c_values): result = [0 for ri in range(len(str_f_values))] f_values = [] c_values = [] # Convert numeric strings to numbers for i in range(len(str_f_values)): 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] f_values.append(float(str_f_values[i])) 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] c_values.append(float(str_c_values[i])) # End of missing exponent marker correction 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))] if (len(f_values) != len(c_values)): return [] f_log_values = [0.0 for j in range(len(f_values))] c_log_values = [0.0 for j in range(len(c_values))] # End string to number conversion # Evaluate the maximum scale max_f_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)) : if f_values[j] < 0.0: f_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 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 (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): result[i] = 1 else: warning_scale = 10.0**(int(max_f_log - f_log_values[i])) difference = c_values[i] - f_values[i] fractional = 1.0 for si in range(len(f_values)): if (f_values[i] != 0): sign = 1.0 if f_values[i] > 0.0 else -1.0 log_f_value = log10(sign * f_values[i]) if (log_f_value > max_f_log): max_f_log = log_f_value if (c_values[i] != 0): sign = 1.0 if c_values[i] > 0.0 else -1.0 log_c_value = log10(sign * c_values[i]) if (log_c_value > max_c_log): max_c_log = log_c_value if (max_f_log == -1.0e12): max_f_log = 0.0 if (max_c_log == -1.0e12): max_c_log = 0.0 # End of maximum scale evaluation # Compare the numbers for i in range(len(f_values)): if (f_values[i] != c_values[i]): if (f_values[i] != 0.0): fractional = difference / f_values[i] sign = 1.0 if f_values[i] > 0.0 else -1.0 log_f_value = log10(sign * f_values[i]) if (log_f_value > max_f_log - 5.0): scale = 10.0**(log_f_value - max_f_log) fractional = scale * (f_values[i] - c_values[i]) / f_values[i] if (fractional < 0.0): fractional *= -1.0 if (fractional < warning_scale * config['warning_threshold']): result[i] = 2 else: result[i] = 3 if (fractional <= config['warning_threshold']): result[i] = 2 else: result[i] = 3 else: result[i] = 1 else: # f_values[i] == 0 and c_values[i] != 0 sign = 1.0 if c_values[i] > 0.0 else -1.0 log_c_value = log10(sign * c_values[i]) if (log_c_value > max_c_log - 5.0): scale = 10.0**(log_c_value - max_c_log) fractional = scale * (c_values[i] - f_values[i]) / c_values[i] if (fractional < 0.0): fractional *= -1.0 if (fractional <= config['warning_threshold']): result[i] = 2 else: result[i] = 3 else: result[i] = 1 # End number comparison return result ## \brief Parse the command line arguments. Loading Loading
src/scripts/pycompare.py +55 −32 Original line number Diff line number Diff line Loading @@ -230,7 +230,7 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=4, log_file=None): if (len(severities) > 0): if (severities[-1] == 0): log_line = ( log_line + c_groups[-1] + c_line[c_ends[-1]:len(c_line) - 2] log_line + c_groups[-1] + c_line[c_ends[-1]:len(c_line) - 1] ) elif (severities[-1] == 1): log_line = ( Loading Loading @@ -291,50 +291,73 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=4, log_file=None): # \returns result: `array(int)` An array of severity codes ordered as the # input numeric values. def mismatch_severities(str_f_values, str_c_values, config): result = [] if len(str_f_values) == len(str_c_values): result = [0 for ri in range(len(str_f_values))] f_values = [] c_values = [] # Convert numeric strings to numbers for i in range(len(str_f_values)): 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] f_values.append(float(str_f_values[i])) 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] c_values.append(float(str_c_values[i])) # End of missing exponent marker correction 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))] if (len(f_values) != len(c_values)): return [] f_log_values = [0.0 for j in range(len(f_values))] c_log_values = [0.0 for j in range(len(c_values))] # End string to number conversion # Evaluate the maximum scale max_f_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)) : if f_values[j] < 0.0: f_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 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 (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): result[i] = 1 else: warning_scale = 10.0**(int(max_f_log - f_log_values[i])) difference = c_values[i] - f_values[i] fractional = 1.0 for si in range(len(f_values)): if (f_values[i] != 0): sign = 1.0 if f_values[i] > 0.0 else -1.0 log_f_value = log10(sign * f_values[i]) if (log_f_value > max_f_log): max_f_log = log_f_value if (c_values[i] != 0): sign = 1.0 if c_values[i] > 0.0 else -1.0 log_c_value = log10(sign * c_values[i]) if (log_c_value > max_c_log): max_c_log = log_c_value if (max_f_log == -1.0e12): max_f_log = 0.0 if (max_c_log == -1.0e12): max_c_log = 0.0 # End of maximum scale evaluation # Compare the numbers for i in range(len(f_values)): if (f_values[i] != c_values[i]): if (f_values[i] != 0.0): fractional = difference / f_values[i] sign = 1.0 if f_values[i] > 0.0 else -1.0 log_f_value = log10(sign * f_values[i]) if (log_f_value > max_f_log - 5.0): scale = 10.0**(log_f_value - max_f_log) fractional = scale * (f_values[i] - c_values[i]) / f_values[i] if (fractional < 0.0): fractional *= -1.0 if (fractional < warning_scale * config['warning_threshold']): result[i] = 2 else: result[i] = 3 if (fractional <= config['warning_threshold']): result[i] = 2 else: result[i] = 3 else: result[i] = 1 else: # f_values[i] == 0 and c_values[i] != 0 sign = 1.0 if c_values[i] > 0.0 else -1.0 log_c_value = log10(sign * c_values[i]) if (log_c_value > max_c_log - 5.0): scale = 10.0**(log_c_value - max_c_log) fractional = scale * (c_values[i] - f_values[i]) / c_values[i] if (fractional < 0.0): fractional *= -1.0 if (fractional <= config['warning_threshold']): result[i] = 2 else: result[i] = 3 else: result[i] = 1 # End number comparison return result ## \brief Parse the command line arguments. Loading