Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
8b020888
Commit
8b020888
authored
Aug 12, 2016
by
Matthieu Schaller
Browse files
Updated diffing script to only check relative differences if the numbers are larger than 1e-6.
parent
6d077c19
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/difffloat.py
View file @
8b020888
...
...
@@ -89,13 +89,12 @@ for i in range(n_lines_to_check):
abs_diff
=
abs
(
data1
[
i
,
j
]
-
data2
[
i
,
j
])
sum
=
abs
(
data1
[
i
,
j
]
+
data2
[
i
,
j
])
if
abs
(
data1
[
i
,
j
])
+
abs
(
data2
[
i
,
j
])
<
2.5e-7
:
continue
if
sum
>
0
:
rel_diff
=
abs
(
data1
[
i
,
j
]
-
data2
[
i
,
j
])
/
sum
else
:
rel_diff
=
0.
if
(
abs_diff
>
absTol
[
j
]):
if
(
abs_diff
>
1.1
*
absTol
[
j
]):
print
"Absolute difference larger than tolerance (%e) for particle %d, column %d:"
%
(
absTol
[
j
],
i
,
j
)
print
"%10s: a = %e"
%
(
"File 1"
,
data1
[
i
,
j
])
print
"%10s: b = %e"
%
(
"File 2"
,
data2
[
i
,
j
])
...
...
@@ -103,7 +102,9 @@ for i in range(n_lines_to_check):
print
""
error
=
True
if
(
rel_diff
>
relTol
[
j
]):
if
abs
(
data1
[
i
,
j
])
<
1e-6
and
+
abs
(
data2
[
i
,
j
])
<
1e-6
:
continue
if
(
rel_diff
>
1.1
*
relTol
[
j
]):
print
"Relative difference larger than tolerance (%e) for particle %d, column %d:"
%
(
relTol
[
j
],
i
,
j
)
print
"%10s: a = %e"
%
(
"File 1"
,
data1
[
i
,
j
])
print
"%10s: b = %e"
%
(
"File 2"
,
data2
[
i
,
j
])
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment