Loading src/scripts/pycompare.py +37 −12 Original line number Diff line number Diff line Loading @@ -343,6 +343,7 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=4, log_file=None): log_line + "</code><span style=\"font-weight: bold; color: rgb(255,0,0)\"><code>" + c_groups[-1] + "</code></span><code>" + c_line[c_ends[-1]:len(c_line) - 2] ) if ((not config['hide_noise']) or warnings > 0 or errors > 0): log_file.write(log_line + "</code></pre></div>\n") log_file.write(ref_line) else: # The two lines contain a different number of numeric values Loading Loading @@ -430,9 +431,12 @@ def mismatch_severities(str_f_values, str_c_values, config): if (fractional <= config['warning_threshold']): result[i] = 2 else: if (log_f_value > config['data_order']): result[i] = 3 else: result[i] = 1 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]) Loading @@ -443,9 +447,12 @@ def mismatch_severities(str_f_values, str_c_values, config): if (fractional <= config['warning_threshold']): result[i] = 2 else: if (log_c_value > config['data_order']): result[i] = 3 else: result[i] = 1 else: result[i] = 1 # End number comparison return result Loading @@ -460,25 +467,40 @@ def mismatch_severities(str_f_values, str_c_values, config): # \returns config: `dict` A dictionary containing the script configuration. def parse_arguments(): config = { 'fortran_file_name': '', 'c_file_name': '', 'check_all': True, 'data_order': -99.0, 'fortran_file_name': '', 'full_log': False, 'help_mode': False, 'hide_noise': False, 'html_output': 'pycompare.html', 'linewise': True, 'log_html': False, 'html_output': 'pycompare.html', 'say_progress': True, 'warning_threshold': 0.005, 'help_mode': False, 'check_all': True, } arg_index = 1 skip_arg = False for arg in argv[1:]: if skip_arg: skip_arg = False continue split_arg = arg.split("=") if (arg.startswith("--ffile")): config['fortran_file_name'] = split_arg[1] config['fortran_file_name'] = argv[arg_index + 1] arg_index += 1 skip_arg = True elif (arg.startswith("--cfile")): config['c_file_name'] = split_arg[1] config['c_file_name'] = argv[arg_index + 1] arg_index += 1 skip_arg = True elif (arg.startswith("--data-order")): config['data_order'] = float(split_arg[1]) elif (arg.startswith("--full")): config['full_log'] = True elif (arg.startswith("--hide-noise")): config['hide_noise'] = True elif (arg.startswith("--html")): config['log_html'] = True if (len(split_arg) == 2): Loading @@ -495,6 +517,7 @@ def parse_arguments(): config['check_all'] = False else: raise Exception("Unrecognized argument \'{0:s}\'".format(arg)) arg_index += 1 return config ## \brief Print a command-line help summary. Loading @@ -507,10 +530,12 @@ def print_help(): print("Usage: \"./pycompare.py OPTIONS\" ") print(" ") print("Valid options are: ") print("--ffile=FORTRAN_OUTPUT File containing the output of the FORTRAN code (mandatory).") print("--cfile=C++_OUTPUT File containing the output of the C++ code (mandatory).") print("--ffile FORTRAN_OUTPUT File containing the output of the FORTRAN code (mandatory).") print("--cfile C++_OUTPUT File containing the output of the C++ code (mandatory).") print("--data-order=ORDER Consider data only down to specified order (default order is -99).") print("--full Print all lines to log file (default prints only mismatches).") print("--help Print this help and exit.") print("--hide-noise Hide noise in reports (default is to show it).") print("--html[=OPT_OUTPUT_NAME] Enable logging to HTML file (default logs to \"pycompare.html\").") print("--linewise Load only one line at a time. Useful to compare big files (True by default).") print("--no-progress Disable progress logging.") Loading Loading
src/scripts/pycompare.py +37 −12 Original line number Diff line number Diff line Loading @@ -343,6 +343,7 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=4, log_file=None): log_line + "</code><span style=\"font-weight: bold; color: rgb(255,0,0)\"><code>" + c_groups[-1] + "</code></span><code>" + c_line[c_ends[-1]:len(c_line) - 2] ) if ((not config['hide_noise']) or warnings > 0 or errors > 0): log_file.write(log_line + "</code></pre></div>\n") log_file.write(ref_line) else: # The two lines contain a different number of numeric values Loading Loading @@ -430,9 +431,12 @@ def mismatch_severities(str_f_values, str_c_values, config): if (fractional <= config['warning_threshold']): result[i] = 2 else: if (log_f_value > config['data_order']): result[i] = 3 else: result[i] = 1 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]) Loading @@ -443,9 +447,12 @@ def mismatch_severities(str_f_values, str_c_values, config): if (fractional <= config['warning_threshold']): result[i] = 2 else: if (log_c_value > config['data_order']): result[i] = 3 else: result[i] = 1 else: result[i] = 1 # End number comparison return result Loading @@ -460,25 +467,40 @@ def mismatch_severities(str_f_values, str_c_values, config): # \returns config: `dict` A dictionary containing the script configuration. def parse_arguments(): config = { 'fortran_file_name': '', 'c_file_name': '', 'check_all': True, 'data_order': -99.0, 'fortran_file_name': '', 'full_log': False, 'help_mode': False, 'hide_noise': False, 'html_output': 'pycompare.html', 'linewise': True, 'log_html': False, 'html_output': 'pycompare.html', 'say_progress': True, 'warning_threshold': 0.005, 'help_mode': False, 'check_all': True, } arg_index = 1 skip_arg = False for arg in argv[1:]: if skip_arg: skip_arg = False continue split_arg = arg.split("=") if (arg.startswith("--ffile")): config['fortran_file_name'] = split_arg[1] config['fortran_file_name'] = argv[arg_index + 1] arg_index += 1 skip_arg = True elif (arg.startswith("--cfile")): config['c_file_name'] = split_arg[1] config['c_file_name'] = argv[arg_index + 1] arg_index += 1 skip_arg = True elif (arg.startswith("--data-order")): config['data_order'] = float(split_arg[1]) elif (arg.startswith("--full")): config['full_log'] = True elif (arg.startswith("--hide-noise")): config['hide_noise'] = True elif (arg.startswith("--html")): config['log_html'] = True if (len(split_arg) == 2): Loading @@ -495,6 +517,7 @@ def parse_arguments(): config['check_all'] = False else: raise Exception("Unrecognized argument \'{0:s}\'".format(arg)) arg_index += 1 return config ## \brief Print a command-line help summary. Loading @@ -507,10 +530,12 @@ def print_help(): print("Usage: \"./pycompare.py OPTIONS\" ") print(" ") print("Valid options are: ") print("--ffile=FORTRAN_OUTPUT File containing the output of the FORTRAN code (mandatory).") print("--cfile=C++_OUTPUT File containing the output of the C++ code (mandatory).") print("--ffile FORTRAN_OUTPUT File containing the output of the FORTRAN code (mandatory).") print("--cfile C++_OUTPUT File containing the output of the C++ code (mandatory).") print("--data-order=ORDER Consider data only down to specified order (default order is -99).") print("--full Print all lines to log file (default prints only mismatches).") print("--help Print this help and exit.") print("--hide-noise Hide noise in reports (default is to show it).") print("--html[=OPT_OUTPUT_NAME] Enable logging to HTML file (default logs to \"pycompare.html\").") print("--linewise Load only one line at a time. Useful to compare big files (True by default).") print("--no-progress Disable progress logging.") Loading