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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Giacomo Mulas
NP_TMcode
Commits
82821256
Commit
82821256
authored
10 months ago
by
Giovanni La Mura
Browse files
Options
Downloads
Patches
Plain Diff
Enable optional user noise threshold in pycompare
parent
0014260b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/scripts/pycompare.py
+37
-12
37 additions, 12 deletions
src/scripts/pycompare.py
with
37 additions
and
12 deletions
src/scripts/pycompare.py
+
37
−
12
View file @
82821256
...
@@ -343,6 +343,7 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=4, log_file=None):
...
@@ -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>
"
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
]
+
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
(
log_line
+
"
</code></pre></div>
\n
"
)
log_file
.
write
(
ref_line
)
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
...
@@ -430,9 +431,12 @@ def mismatch_severities(str_f_values, str_c_values, config):
...
@@ -430,9 +431,12 @@ def mismatch_severities(str_f_values, str_c_values, config):
if
(
fractional
<=
config
[
'
warning_threshold
'
]):
if
(
fractional
<=
config
[
'
warning_threshold
'
]):
result
[
i
]
=
2
result
[
i
]
=
2
else
:
else
:
if
(
log_f_value
>
config
[
'
data_order
'
]):
result
[
i
]
=
3
result
[
i
]
=
3
else
:
else
:
result
[
i
]
=
1
result
[
i
]
=
1
else
:
result
[
i
]
=
1
else
:
# f_values[i] == 0 and c_values[i] != 0
else
:
# f_values[i] == 0 and c_values[i] != 0
sign
=
1.0
if
c_values
[
i
]
>
0.0
else
-
1.0
sign
=
1.0
if
c_values
[
i
]
>
0.0
else
-
1.0
log_c_value
=
log10
(
sign
*
c_values
[
i
])
log_c_value
=
log10
(
sign
*
c_values
[
i
])
...
@@ -443,9 +447,12 @@ def mismatch_severities(str_f_values, str_c_values, config):
...
@@ -443,9 +447,12 @@ def mismatch_severities(str_f_values, str_c_values, config):
if
(
fractional
<=
config
[
'
warning_threshold
'
]):
if
(
fractional
<=
config
[
'
warning_threshold
'
]):
result
[
i
]
=
2
result
[
i
]
=
2
else
:
else
:
if
(
log_c_value
>
config
[
'
data_order
'
]):
result
[
i
]
=
3
result
[
i
]
=
3
else
:
else
:
result
[
i
]
=
1
result
[
i
]
=
1
else
:
result
[
i
]
=
1
# End number comparison
# End number comparison
return
result
return
result
...
@@ -460,25 +467,40 @@ def mismatch_severities(str_f_values, str_c_values, config):
...
@@ -460,25 +467,40 @@ def mismatch_severities(str_f_values, str_c_values, config):
# \returns config: `dict` A dictionary containing the script configuration.
# \returns config: `dict` A dictionary containing the script configuration.
def
parse_arguments
():
def
parse_arguments
():
config
=
{
config
=
{
'
fortran_file_name
'
:
''
,
'
c_file_name
'
:
''
,
'
c_file_name
'
:
''
,
'
check_all
'
:
True
,
'
data_order
'
:
-
99.0
,
'
fortran_file_name
'
:
''
,
'
full_log
'
:
False
,
'
full_log
'
:
False
,
'
help_mode
'
:
False
,
'
hide_noise
'
:
False
,
'
html_output
'
:
'
pycompare.html
'
,
'
linewise
'
:
True
,
'
linewise
'
:
True
,
'
log_html
'
:
False
,
'
log_html
'
:
False
,
'
html_output
'
:
'
pycompare.html
'
,
'
say_progress
'
:
True
,
'
say_progress
'
:
True
,
'
warning_threshold
'
:
0.005
,
'
warning_threshold
'
:
0.005
,
'
help_mode
'
:
False
,
'
check_all
'
:
True
,
}
}
arg_index
=
1
skip_arg
=
False
for
arg
in
argv
[
1
:]:
for
arg
in
argv
[
1
:]:
if
skip_arg
:
skip_arg
=
False
continue
split_arg
=
arg
.
split
(
"
=
"
)
split_arg
=
arg
.
split
(
"
=
"
)
if
(
arg
.
startswith
(
"
--ffile
"
)):
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
"
)):
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
"
)):
elif
(
arg
.
startswith
(
"
--full
"
)):
config
[
'
full_log
'
]
=
True
config
[
'
full_log
'
]
=
True
elif
(
arg
.
startswith
(
"
--hide-noise
"
)):
config
[
'
hide_noise
'
]
=
True
elif
(
arg
.
startswith
(
"
--html
"
)):
elif
(
arg
.
startswith
(
"
--html
"
)):
config
[
'
log_html
'
]
=
True
config
[
'
log_html
'
]
=
True
if
(
len
(
split_arg
)
==
2
):
if
(
len
(
split_arg
)
==
2
):
...
@@ -495,6 +517,7 @@ def parse_arguments():
...
@@ -495,6 +517,7 @@ def parse_arguments():
config
[
'
check_all
'
]
=
False
config
[
'
check_all
'
]
=
False
else
:
else
:
raise
Exception
(
"
Unrecognized argument
\'
{0:s}
\'
"
.
format
(
arg
))
raise
Exception
(
"
Unrecognized argument
\'
{0:s}
\'
"
.
format
(
arg
))
arg_index
+=
1
return
config
return
config
## \brief Print a command-line help summary.
## \brief Print a command-line help summary.
...
@@ -507,10 +530,12 @@ def print_help():
...
@@ -507,10 +530,12 @@ def print_help():
print
(
"
Usage:
\"
./pycompare.py OPTIONS
\"
"
)
print
(
"
Usage:
\"
./pycompare.py OPTIONS
\"
"
)
print
(
"
"
)
print
(
"
"
)
print
(
"
Valid options are:
"
)
print
(
"
Valid options are:
"
)
print
(
"
--ffile=FORTRAN_OUTPUT File containing the output of the FORTRAN 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
(
"
--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
(
"
--full Print all lines to log file (default prints only mismatches).
"
)
print
(
"
--help Print this help and exit.
"
)
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
(
"
--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
(
"
--linewise Load only one line at a time. Useful to compare big files (True by default).
"
)
print
(
"
--no-progress Disable progress logging.
"
)
print
(
"
--no-progress Disable progress logging.
"
)
...
...
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