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

Write original lines in comparison script

parent ae8572af
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@
# 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
# 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 code and to flag all the possible inconsistencies according to various
# severity levels (namely: NOISE, WARNING, and ERROR).
......@@ -105,7 +105,7 @@ def compare_files(config):
line_count = len(f_lines)
num_len = 1
if (line_count > 0):
num_len = int(log10(line_count)) + 1
num_len = max(4, int(log10(line_count)) + 1)
if (config['log_html']):
l_file = open(config['html_output'], 'w')
l_file.write("<!DOCTYPE html>\n")
......@@ -157,11 +157,13 @@ def compare_files(config):
#
# \returns mismatch_count: `tuple(int, int, int)` A tuple that bundles
# 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
warnings = 0
noisy = 0
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 log_file is not None:
if (config['full_log']):
......@@ -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]
)
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
if (log_file is not None):
num_format = " <div><pre><code>{0:0%dd}"%num_len
......@@ -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>"
)
log_file.write(log_line + "</code></pre></div>\n")
log_file.write(ref_line)
errors += 1
return (errors, warnings, noisy)
......
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