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
bad9e0e1
Commit
bad9e0e1
authored
11 months ago
by
Giovanni La Mura
Browse files
Options
Downloads
Patches
Plain Diff
Reorganize numeric noise detection logic
parent
88402e26
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
+55
-32
55 additions, 32 deletions
src/scripts/pycompare.py
with
55 additions
and
32 deletions
src/scripts/pycompare.py
+
55
−
32
View file @
bad9e0e1
...
@@ -230,7 +230,7 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=4, log_file=None):
...
@@ -230,7 +230,7 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=4, log_file=None):
if
(
len
(
severities
)
>
0
):
if
(
len
(
severities
)
>
0
):
if
(
severities
[
-
1
]
==
0
):
if
(
severities
[
-
1
]
==
0
):
log_line
=
(
log_line
=
(
log_line
+
c_groups
[
-
1
]
+
c_line
[
c_ends
[
-
1
]:
len
(
c_line
)
-
2
]
log_line
+
c_groups
[
-
1
]
+
c_line
[
c_ends
[
-
1
]:
len
(
c_line
)
-
1
]
)
)
elif
(
severities
[
-
1
]
==
1
):
elif
(
severities
[
-
1
]
==
1
):
log_line
=
(
log_line
=
(
...
@@ -291,50 +291,73 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=4, log_file=None):
...
@@ -291,50 +291,73 @@ def compare_lines(f_line, c_line, config, line_num=0, num_len=4, log_file=None):
# \returns result: `array(int)` An array of severity codes ordered as the
# \returns result: `array(int)` An array of severity codes ordered as the
# input numeric values.
# input numeric values.
def
mismatch_severities
(
str_f_values
,
str_c_values
,
config
):
def
mismatch_severities
(
str_f_values
,
str_c_values
,
config
):
result
=
[
0
for
ri
in
range
(
len
(
str_f_values
))]
result
=
[]
for
i
in
range
(
len
(
str_f_values
)):
if
len
(
str_f_values
)
==
len
(
str_c_values
):
if
(
str_f_values
[
i
]
!=
str_c_values
[
i
]):
result
=
[
0
for
ri
in
range
(
len
(
str_f_values
))]
f_values
=
[]
c_values
=
[]
# Convert numeric strings to numbers
for
i
in
range
(
len
(
str_f_values
)):
# Add the exponent marker if it is missing
# Add the exponent marker if it is missing
temp_str_value
=
str_f_values
[
i
][
1
:]
temp_str_value
=
str_f_values
[
i
][
1
:]
split_temp
=
temp_str_value
.
split
(
'
-
'
)
split_temp
=
temp_str_value
.
split
(
'
-
'
)
if
len
(
split_temp
)
>
1
:
if
len
(
split_temp
)
>
1
:
if
(
split_temp
[
0
][
-
1
]
!=
'
E
'
):
if
(
split_temp
[
0
][
-
1
]
!=
'
E
'
):
str_f_values
[
i
]
=
str_f_values
[
i
][
0
]
+
split_temp
[
0
]
+
"
E-
"
+
split_temp
[
1
]
str_f_values
[
i
]
=
str_f_values
[
i
][
0
]
+
split_temp
[
0
]
+
"
E-
"
+
split_temp
[
1
]
f_values
.
append
(
float
(
str_f_values
[
i
]))
temp_str_value
=
str_c_values
[
i
][
1
:]
temp_str_value
=
str_c_values
[
i
][
1
:]
split_temp
=
temp_str_value
.
split
(
'
-
'
)
split_temp
=
temp_str_value
.
split
(
'
-
'
)
if
len
(
split_temp
)
>
1
:
if
len
(
split_temp
)
>
1
:
if
(
split_temp
[
0
][
-
1
]
!=
'
E
'
):
if
(
split_temp
[
0
][
-
1
]
!=
'
E
'
):
str_c_values
[
i
]
=
str_c_values
[
i
][
0
]
+
split_temp
[
0
]
+
"
E-
"
+
split_temp
[
1
]
str_c_values
[
i
]
=
str_c_values
[
i
][
0
]
+
split_temp
[
0
]
+
"
E-
"
+
split_temp
[
1
]
c_values
.
append
(
float
(
str_c_values
[
i
]))
# End of missing exponent marker correction
# End of missing exponent marker correction
f_values
=
[
float
(
str_f_values
[
j
])
for
j
in
range
(
len
(
str_f_values
))]
# End string to number conversion
c_values
=
[
float
(
str_c_values
[
j
])
for
j
in
range
(
len
(
str_c_values
))]
# Evaluate the maximum scale
if
(
len
(
f_values
)
!=
len
(
c_values
)):
return
[]
max_f_log
=
-
1.0e12
f_log_values
=
[
0.0
for
j
in
range
(
len
(
f_values
))]
max_c_log
=
-
1.0e12
c_log_values
=
[
0.0
for
j
in
range
(
len
(
c_values
))]
for
si
in
range
(
len
(
f_values
)):
max_f_log
=
-
1.0e12
if
(
f_values
[
i
]
!=
0
):
max_c_log
=
-
1.0e12
sign
=
1.0
if
f_values
[
i
]
>
0.0
else
-
1.0
min_f_log
=
1.0e12
log_f_value
=
log10
(
sign
*
f_values
[
i
])
min_c_log
=
1.0e12
if
(
log_f_value
>
max_f_log
):
max_f_log
=
log_f_value
for
j
in
range
(
len
(
f_values
))
:
if
(
c_values
[
i
]
!=
0
):
if
f_values
[
j
]
<
0.0
:
f_values
[
j
]
*=
-
1.0
sign
=
1.0
if
c_values
[
i
]
>
0.0
else
-
1.0
if
c_values
[
j
]
<
0.0
:
c_values
[
j
]
*=
-
1.0
log_c_value
=
log10
(
sign
*
c_values
[
i
])
f_log_values
[
j
]
=
log10
(
f_values
[
j
])
if
f_values
[
j
]
>
0.0
else
-
999
if
(
log_c_value
>
max_c_log
):
max_c_log
=
log_c_value
c_log_values
[
j
]
=
log10
(
c_values
[
j
])
if
c_values
[
j
]
>
0.0
else
-
999
if
(
max_f_log
==
-
1.0e12
):
max_f_log
=
0.0
if
(
f_log_values
[
j
]
>
max_f_log
):
max_f_log
=
f_log_values
[
j
]
if
(
max_c_log
==
-
1.0e12
):
max_c_log
=
0.0
if
(
c_log_values
[
j
]
>
max_c_log
):
max_c_log
=
c_log_values
[
j
]
# End of maximum scale evaluation
if
(
f_log_values
[
j
]
<
min_f_log
):
min_f_log
=
f_log_values
[
j
]
# Compare the numbers
if
(
c_log_values
[
j
]
<
min_c_log
):
min_c_log
=
c_log_values
[
j
]
for
i
in
range
(
len
(
f_values
)):
if
(
c_log_values
[
i
]
<
max_c_log
-
5.0
and
f_log_values
[
i
]
<
max_f_log
-
5.0
):
if
(
f_values
[
i
]
!=
c_values
[
i
]):
result
[
i
]
=
1
else
:
warning_scale
=
10.0
**
(
int
(
max_f_log
-
f_log_values
[
i
]))
difference
=
c_values
[
i
]
-
f_values
[
i
]
fractional
=
1.0
if
(
f_values
[
i
]
!=
0.0
):
if
(
f_values
[
i
]
!=
0.0
):
fractional
=
difference
/
f_values
[
i
]
sign
=
1.0
if
f_values
[
i
]
>
0.0
else
-
1.0
if
(
fractional
<
0.0
):
fractional
*=
-
1.0
log_f_value
=
log10
(
sign
*
f_values
[
i
])
if
(
fractional
<
warning_scale
*
config
[
'
warning_threshold
'
]):
result
[
i
]
=
2
if
(
log_f_value
>
max_f_log
-
5.0
):
else
:
result
[
i
]
=
3
scale
=
10.0
**
(
log_f_value
-
max_f_log
)
fractional
=
scale
*
(
f_values
[
i
]
-
c_values
[
i
])
/
f_values
[
i
]
if
(
fractional
<
0.0
):
fractional
*=
-
1.0
if
(
fractional
<=
config
[
'
warning_threshold
'
]):
result
[
i
]
=
2
else
:
result
[
i
]
=
3
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
])
if
(
log_c_value
>
max_c_log
-
5.0
):
scale
=
10.0
**
(
log_c_value
-
max_c_log
)
fractional
=
scale
*
(
c_values
[
i
]
-
f_values
[
i
])
/
c_values
[
i
]
if
(
fractional
<
0.0
):
fractional
*=
-
1.0
if
(
fractional
<=
config
[
'
warning_threshold
'
]):
result
[
i
]
=
2
else
:
result
[
i
]
=
3
else
:
result
[
i
]
=
1
# End number comparison
return
result
return
result
## \brief Parse the command line arguments.
## \brief Parse the command line arguments.
...
...
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