Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dumux-repositories
dumux
Commits
3aa86f17
Commit
3aa86f17
authored
2 years ago
by
Timo Koch
Browse files
Options
Downloads
Patches
Plain Diff
[bin/testing] Add option to ignore fields in the test driver
parent
5c9e3715
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3353
Feature/fieldcompare
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bin/testing/fuzzycomparedata.py
+20
-1
20 additions, 1 deletion
bin/testing/fuzzycomparedata.py
bin/testing/fuzzycomparevtu.py
+23
-1
23 additions, 1 deletion
bin/testing/fuzzycomparevtu.py
bin/testing/runtest.py
+54
-12
54 additions, 12 deletions
bin/testing/runtest.py
with
97 additions
and
14 deletions
bin/testing/fuzzycomparedata.py
+
20
−
1
View file @
3aa86f17
...
...
@@ -11,6 +11,10 @@ import json
import
sys
from
fuzzycomparevtu
import
isFuzzyEqualText
# Note: these issues can be improved on by factoring out functions
# but we ignore it for know ("legacy code")
# pylint: disable=too-many-arguments,too-many-locals,too-many-branches,too-many-statements
def
compareData
(
dataFile1
,
...
...
@@ -19,8 +23,9 @@ def compareData(
absolute
=
1.5e-7
,
relative
=
1e-2
,
zeroValueThreshold
=
None
,
ignoreFields
=
None
,
verbose
=
True
,
):
# pylint: disable=too-many-arguments
):
"""
take two data files and compare them. Returns an exit key as returnvalue.
Arguments:
...
...
@@ -40,6 +45,8 @@ def compareData(
A dictionary of parameter value pairs that set the threshold under
which a number is treated as zero for a certain parameter. Use this parameter if
you have to avoid comparisons of very small numbers for a certain parameter.
ignoreFields: list
A list of field names to be ignored in the comparison
verbose : bool
If the script should produce informative output. Enabled by default as the details
give the tester a lot more information on why tests fail.
...
...
@@ -54,6 +61,11 @@ def compareData(
zeroValueThreshold
=
zeroValueThreshold
or
{}
# implement ignoring fields by setting a very high threshold
if
ignoreFields
is
not
None
:
for
field
in
ignoreFields
:
zeroValueThreshold
[
field
]
=
1e100
# construct element tree from data files
with
open
(
dataFile1
,
"
r
"
)
as
data1
:
data1
=
list
(
csv
.
reader
(
data1
,
delimiter
=
delimiter
))
...
...
@@ -128,6 +140,12 @@ if __name__ == "__main__":
'
e.g. {
"
vel
"
:1e-7,
"
delP
"
:1.0}
'
),
)
parser
.
add_argument
(
"
-i
"
,
"
--ignore
"
,
nargs
=
"
+
"
,
help
=
(
"
Space separated list of fields to ignore in the comparison
"
),
)
args
=
vars
(
parser
.
parse_args
())
sys
.
exit
(
...
...
@@ -139,5 +157,6 @@ if __name__ == "__main__":
args
[
"
relative
"
],
args
[
"
zeroThreshold
"
],
args
[
"
verbose
"
],
args
[
"
ignore
"
],
)
)
This diff is collapsed.
Click to expand it.
bin/testing/fuzzycomparevtu.py
+
23
−
1
View file @
3aa86f17
...
...
@@ -19,7 +19,15 @@ import functools
# pylint: disable=too-many-arguments,too-many-locals,too-many-branches,too-many-statements
def
compareVTK
(
vtk1
,
vtk2
,
absolute
=
1.5e-7
,
relative
=
1e-2
,
zeroValueThreshold
=
None
,
verbose
=
True
):
def
compareVTK
(
vtk1
,
vtk2
,
absolute
=
1.5e-7
,
relative
=
1e-2
,
zeroValueThreshold
=
None
,
ignoreFields
=
None
,
verbose
=
True
,
):
"""
take two vtk files and compare them. Returns an exit key as returnvalue.
Arguments:
...
...
@@ -41,6 +49,8 @@ def compareVTK(vtk1, vtk2, absolute=1.5e-7, relative=1e-2, zeroValueThreshold=No
A dictionary of parameter value pairs that set the threshold under
which a number is treated as zero for a certain parameter. Use this parameter if
you have to avoid comparisons of very small numbers for a certain parameter.
ignoreFields: list
A list of field names to be ignored in the comparison
verbose : bool
If the script should produce informative output. Enabled by default as the details
give the tester a lot more information on why tests fail.
...
...
@@ -54,6 +64,11 @@ def compareVTK(vtk1, vtk2, absolute=1.5e-7, relative=1e-2, zeroValueThreshold=No
zeroValueThreshold
=
zeroValueThreshold
or
{}
# implement ignoring fields by setting a very high threshold
if
ignoreFields
is
not
None
:
for
field
in
ignoreFields
:
zeroValueThreshold
[
field
]
=
1e100
# convert parallel vtu to sequential vtu if necessary
convertedFromParallelVtu
=
False
if
vtk1
.
endswith
(
"
.pvtu
"
):
...
...
@@ -668,6 +683,12 @@ if __name__ == "__main__":
'
e.g. {
"
vel
"
:1e-7,
"
delP
"
:1.0}
'
),
)
parser
.
add_argument
(
"
-i
"
,
"
--ignore
"
,
nargs
=
"
+
"
,
help
=
(
"
Space separated list of fields to ignore in the comparison
"
),
)
parser
.
add_argument
(
"
-v
"
,
"
--verbose
"
,
dest
=
"
verbose
"
,
action
=
"
store_true
"
)
parser
.
add_argument
(
"
--no-verbose
"
,
dest
=
"
verbose
"
,
action
=
"
store_false
"
)
parser
.
set_defaults
(
verbose
=
True
)
...
...
@@ -681,5 +702,6 @@ if __name__ == "__main__":
args
[
"
relative
"
],
args
[
"
zeroThreshold
"
],
args
[
"
verbose
"
],
args
[
"
ignore
"
],
)
)
This diff is collapsed.
Click to expand it.
bin/testing/runtest.py
+
54
−
12
View file @
3aa86f17
...
...
@@ -24,6 +24,7 @@ try:
protocols
.
MeshFields
=
meshcompare
.
MeshFields
protocols
.
TabularFields
=
tabularcompare
.
TabularFields
# pylint: disable=too-many-arguments
def
makePredicateSelector
(
relThreshold
,
absThreshold
,
...
...
@@ -43,7 +44,12 @@ try:
return
_selector
def
fieldcompareMeshData
(
source
,
ref
,
absThreshold
=
0.0
,
relThreshold
=
1e-7
,
zeroValueThreshold
=
None
source
,
ref
,
absThreshold
=
0.0
,
relThreshold
=
1e-7
,
zeroValueThreshold
=
None
,
ignoreFields
=
None
,
):
"""
Compares mesh data with the fieldcompare library
"""
...
...
@@ -67,10 +73,17 @@ try:
sourceFields
.
domain
.
set_tolerances
(
abs_tol
=
ScaledTolerance
(
1e-6
),
rel_tol
=
1.5e-7
)
referenceFields
.
domain
.
set_tolerances
(
abs_tol
=
ScaledTolerance
(
1e-6
),
rel_tol
=
1.5e-7
)
compare
=
MeshFieldsComparator
(
source
=
sourceFields
,
reference
=
referenceFields
)
ignoreFields
=
ignoreFields
or
[]
compare
=
MeshFieldsComparator
(
source
=
sourceFields
,
reference
=
referenceFields
,
field_exclusion_filter
=
lambda
name
:
name
in
ignoreFields
,
)
result
=
compare
(
predicate_selector
=
makePredicateSelector
(
relThreshold
,
absThreshold
,
zeroValueThreshold
relThreshold
=
relThreshold
,
absThreshold
=
absThreshold
,
zeroValueThreshold
=
zeroValueThreshold
,
),
fieldcomp_callback
=
DefaultFieldComparisonCallback
(
verbosity
=
1
),
reordering_callback
=
lambda
msg
:
print
(
f
"
--
{
msg
}
"
),
...
...
@@ -82,9 +95,14 @@ try:
return
1
return
0
# pylint: disable=too-many-arguments
def
fieldcompareCSVData
(
source
,
ref
,
delimiter
,
absThreshold
=
0.0
,
relThreshold
=
1e-7
,
zeroValueThreshold
=
None
source
,
ref
,
delimiter
,
absThreshold
=
0.0
,
relThreshold
=
1e-7
,
zeroValueThreshold
=
None
,
ignoreFields
=
None
,
):
"""
Compares CSV data with the fieldcompare library
"""
...
...
@@ -103,13 +121,18 @@ try:
if
not
isinstance
(
referenceFields
,
protocols
.
TabularFields
):
raise
IOError
(
"
Reference file could not been identified as CSV-like file!
"
)
compare
=
FieldDataComparator
(
source
=
sourceFields
,
reference
=
referenceFields
)
ignoreFields
=
ignoreFields
or
[]
compare
=
FieldDataComparator
(
source
=
sourceFields
,
reference
=
referenceFields
,
field_exclusion_filter
=
lambda
name
:
name
in
ignoreFields
,
)
result
=
compare
(
predicate_selector
=
makePredicateSelector
(
relThreshold
,
absThreshold
,
zeroValueThreshold
,
lambda
name
:
f
"
row
{
float
(
name
.
strip
(
'
field_
'
))
}
"
,
relThreshold
=
relThreshold
,
absThreshold
=
absThreshold
,
zeroValueThreshold
=
zeroValueThreshold
,
sourceFieldNameTransform
=
lambda
name
:
f
"
row
{
float
(
name
.
strip
(
'
field_
'
))
}
"
,
),
fieldcomp_callback
=
DefaultFieldComparisonCallback
(
verbosity
=
1
),
)
...
...
@@ -186,6 +209,12 @@ def readCmdParameters():
'
a parameter as a python dict e.g. {
"
vel
"
:1e-7,
"
delP
"
:1.0}
'
),
)
parser
.
add_argument
(
"
-i
"
,
"
--ignore
"
,
nargs
=
"
+
"
,
help
=
(
"
Space separated list of fields to ignore in the comparison
"
),
)
args
=
vars
(
parser
.
parse_args
())
# check parameters
...
...
@@ -236,8 +265,14 @@ def _fuzzyMeshComparison(args):
relThreshold
=
args
[
"
relative
"
]
absThreshold
=
args
[
"
absolute
"
]
zeroValueThreshold
=
args
[
"
zeroThreshold
"
]
ignoreFields
=
args
[
"
ignore
"
]
numFailed
+=
fieldcompareMeshData
(
source
,
ref
,
absThreshold
,
relThreshold
,
zeroValueThreshold
source
,
ref
,
absThreshold
,
relThreshold
,
zeroValueThreshold
,
ignoreFields
,
)
return
int
(
numFailed
>
0
)
...
...
@@ -255,8 +290,15 @@ def _fuzzyDataComparison(args):
relThreshold
=
args
[
"
relative
"
]
absThreshold
=
args
[
"
absolute
"
]
zeroValueThreshold
=
args
[
"
zeroThreshold
"
]
ignoreFields
=
args
[
"
ignore
"
]
numFailed
+=
fieldcompareCSVData
(
source
,
ref
,
delimiter
,
absThreshold
,
relThreshold
,
zeroValueThreshold
source
,
ref
,
delimiter
,
absThreshold
,
relThreshold
,
zeroValueThreshold
,
ignoreFields
,
)
return
int
(
numFailed
>
0
)
...
...
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