Loading src/scripts/pycompare.py +7 −3 Original line number Original line Diff line number Diff line Loading @@ -6,7 +6,7 @@ # Comparing the numeric output can be rendered hard by the amount of information # Comparing the numeric output can be rendered hard by the amount of information # contained in a typical output file and the necessity to determine whether a # contained in a typical output file and the necessity to determine whether a # difference is actually significant or just caused by numeric noise hitting # difference is actually significant or just caused by numeric noise hitting # negligible values. The task of this script is to compare two output files, in # negligible values. The task of `pycompare.py` is to compare two output files, in # the assumption that they were written by the FORTRAN and the C++ versions of # the assumption that they were written by the FORTRAN and the C++ versions of # the code and to flag all the possible inconsistencies according to various # the code and to flag all the possible inconsistencies according to various # severity levels (namely: NOISE, WARNING, and ERROR). # severity levels (namely: NOISE, WARNING, and ERROR). Loading Loading @@ -105,7 +105,7 @@ def compare_files(config): line_count = len(f_lines) line_count = len(f_lines) num_len = 1 num_len = 1 if (line_count > 0): if (line_count > 0): num_len = int(log10(line_count)) + 1 num_len = max(4, int(log10(line_count)) + 1) if (config['log_html']): if (config['log_html']): l_file = open(config['html_output'], 'w') l_file = open(config['html_output'], 'w') l_file.write("<!DOCTYPE html>\n") l_file.write("<!DOCTYPE html>\n") Loading Loading @@ -157,11 +157,13 @@ def compare_files(config): # # # \returns mismatch_count: `tuple(int, int, int)` A tuple that bundles # \returns mismatch_count: `tuple(int, int, int)` A tuple that bundles # together the numbers of detected errors, warnings and noisy values. # together the numbers of detected errors, warnings and noisy values. def compare_lines(f_line, c_line, config, line_num=0, num_len=1, log_file=None): def compare_lines(f_line, c_line, config, line_num=0, num_len=4, log_file=None): errors = 0 errors = 0 warnings = 0 warnings = 0 noisy = 0 noisy = 0 f_line = f_line.replace("D-","E-").replace("D+","E+") f_line = f_line.replace("D-","E-").replace("D+","E+") ref_format = " <div><span style=\"font-weight: bold; color: rgb(125,125,125)\"><pre><code>{0:%ds}"%num_len ref_line = (ref_format + ": {1:s}</code></pre></span></div>\n").format("ORIG", f_line[:-1]) if (f_line == c_line): if (f_line == c_line): if log_file is not None: if log_file is not None: if (config['full_log']): if (config['full_log']): Loading Loading @@ -246,6 +248,7 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=1, log_file=None): + c_groups[-1] + "</code></span><code>" + c_line[c_ends[-1]:len(c_line) - 2] + c_groups[-1] + "</code></span><code>" + c_line[c_ends[-1]:len(c_line) - 2] ) ) log_file.write(log_line + "</code></pre></div>\n") 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 else: # The two lines contain a different number of numeric values if (log_file is not None): if (log_file is not None): num_format = " <div><pre><code>{0:0%dd}"%num_len num_format = " <div><pre><code>{0:0%dd}"%num_len Loading @@ -255,6 +258,7 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=1, log_file=None): + c_line + "</code></span><code>" + c_line + "</code></span><code>" ) ) log_file.write(log_line + "</code></pre></div>\n") log_file.write(log_line + "</code></pre></div>\n") log_file.write(ref_line) errors += 1 errors += 1 return (errors, warnings, noisy) return (errors, warnings, noisy) Loading Loading
src/scripts/pycompare.py +7 −3 Original line number Original line Diff line number Diff line Loading @@ -6,7 +6,7 @@ # Comparing the numeric output can be rendered hard by the amount of information # Comparing the numeric output can be rendered hard by the amount of information # contained in a typical output file and the necessity to determine whether a # contained in a typical output file and the necessity to determine whether a # difference is actually significant or just caused by numeric noise hitting # difference is actually significant or just caused by numeric noise hitting # negligible values. The task of this script is to compare two output files, in # negligible values. The task of `pycompare.py` is to compare two output files, in # the assumption that they were written by the FORTRAN and the C++ versions of # the assumption that they were written by the FORTRAN and the C++ versions of # the code and to flag all the possible inconsistencies according to various # the code and to flag all the possible inconsistencies according to various # severity levels (namely: NOISE, WARNING, and ERROR). # severity levels (namely: NOISE, WARNING, and ERROR). Loading Loading @@ -105,7 +105,7 @@ def compare_files(config): line_count = len(f_lines) line_count = len(f_lines) num_len = 1 num_len = 1 if (line_count > 0): if (line_count > 0): num_len = int(log10(line_count)) + 1 num_len = max(4, int(log10(line_count)) + 1) if (config['log_html']): if (config['log_html']): l_file = open(config['html_output'], 'w') l_file = open(config['html_output'], 'w') l_file.write("<!DOCTYPE html>\n") l_file.write("<!DOCTYPE html>\n") Loading Loading @@ -157,11 +157,13 @@ def compare_files(config): # # # \returns mismatch_count: `tuple(int, int, int)` A tuple that bundles # \returns mismatch_count: `tuple(int, int, int)` A tuple that bundles # together the numbers of detected errors, warnings and noisy values. # together the numbers of detected errors, warnings and noisy values. def compare_lines(f_line, c_line, config, line_num=0, num_len=1, log_file=None): def compare_lines(f_line, c_line, config, line_num=0, num_len=4, log_file=None): errors = 0 errors = 0 warnings = 0 warnings = 0 noisy = 0 noisy = 0 f_line = f_line.replace("D-","E-").replace("D+","E+") f_line = f_line.replace("D-","E-").replace("D+","E+") ref_format = " <div><span style=\"font-weight: bold; color: rgb(125,125,125)\"><pre><code>{0:%ds}"%num_len ref_line = (ref_format + ": {1:s}</code></pre></span></div>\n").format("ORIG", f_line[:-1]) if (f_line == c_line): if (f_line == c_line): if log_file is not None: if log_file is not None: if (config['full_log']): if (config['full_log']): Loading Loading @@ -246,6 +248,7 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=1, log_file=None): + c_groups[-1] + "</code></span><code>" + c_line[c_ends[-1]:len(c_line) - 2] + c_groups[-1] + "</code></span><code>" + c_line[c_ends[-1]:len(c_line) - 2] ) ) log_file.write(log_line + "</code></pre></div>\n") 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 else: # The two lines contain a different number of numeric values if (log_file is not None): if (log_file is not None): num_format = " <div><pre><code>{0:0%dd}"%num_len num_format = " <div><pre><code>{0:0%dd}"%num_len Loading @@ -255,6 +258,7 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=1, log_file=None): + c_line + "</code></span><code>" + c_line + "</code></span><code>" ) ) log_file.write(log_line + "</code></pre></div>\n") log_file.write(log_line + "</code></pre></div>\n") log_file.write(ref_line) errors += 1 errors += 1 return (errors, warnings, noisy) return (errors, warnings, noisy) Loading