Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pygwinc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Kevin Kuns
pygwinc
Commits
4dbf3ce1
Commit
4dbf3ce1
authored
3 years ago
by
Kevin Kuns
Browse files
Options
Downloads
Patches
Plain Diff
add pytest fixture for comparing two sets of traces
parent
504b9e8e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
conftest.py
+53
-0
53 additions, 0 deletions
conftest.py
with
53 additions
and
0 deletions
conftest.py
+
53
−
0
View file @
4dbf3ce1
...
...
@@ -279,6 +279,59 @@ def relfile_test(_file_, request, pre = None, post = None, fname = None):
return
relfile
(
_file_
,
testname
,
fname
=
fname
)
@pytest.fixture
def
compare_noise
(
pprint
):
"""
Fixture to compare two sets of traces
A list of noises passed, failed, and skipped are printed. Comparisons are
skipped if the psd
'
s are sufficiently small (controlled by psd_tol) indicating
that the noise is essentially zero or if a trace is missing.
An assertion error is raised if any noises fail.
"""
import
numpy
as
np
def
compare
(
traces
,
ref_traces
,
psd_tol
=
1e-52
):
passed
=
[]
failed
=
[]
skipped
=
[]
for
ref_trace
in
ref_traces
:
if
np
.
all
(
ref_trace
.
psd
<
psd_tol
):
skipped
.
append
(
ref_trace
.
name
)
continue
try
:
trace
=
traces
[
ref_trace
.
name
]
except
KeyError
:
skipped
.
append
(
ref_trace
.
name
)
continue
if
np
.
allclose
(
trace
.
psd
,
ref_trace
.
psd
,
atol
=
0
):
passed
.
append
(
trace
.
name
)
else
:
failed
.
append
(
trace
.
name
)
pprint
(
'
Noises failed:
'
)
pprint
(
40
*
'
-
'
)
for
noise
in
failed
:
pprint
(
noise
)
pprint
(
40
*
'
+
'
)
pprint
(
'
Noises passed:
'
)
pprint
(
40
*
'
-
'
)
for
noise
in
passed
:
pprint
(
noise
)
pprint
(
40
*
'
+
'
)
pprint
(
'
Noises skipped:
'
)
pprint
(
40
*
'
-
'
)
for
noise
in
skipped
:
pprint
(
noise
)
assert
len
(
failed
)
==
0
return
compare
def
pytest_collection_modifyitems
(
config
,
items
):
"""
Modifies tests to be selectively skipped with command line options
...
...
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