Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NP_TMcode
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Giacomo Mulas
NP_TMcode
Commits
e3294d31
Commit
e3294d31
authored
1 year ago
by
Giovanni La Mura
Browse files
Options
Downloads
Patches
Plain Diff
Write original lines in comparison script
parent
ae8572af
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/scripts/pycompare.py
+7
-3
7 additions, 3 deletions
src/scripts/pycompare.py
with
7 additions
and
3 deletions
src/scripts/pycompare.py
+
7
−
3
View file @
e3294d31
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment