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
Bliss
python-handel
Commits
8d4dc6ef
Commit
8d4dc6ef
authored
Sep 18, 2017
by
Vincent Michel
Browse files
Fix statistics tests
parent
108db296
Pipeline
#1014
passed with stages
in 1 minute and 18 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
handel/interface.py
View file @
8d4dc6ef
...
...
@@ -207,7 +207,7 @@ def get_module_statistics(module):
code
=
handel
.
xiaGetRunData
(
master
,
b
'module_statistics_2'
,
data
)
check_error
(
code
)
# Parse raw data
return
{
channel
:
stats_from_buffer
(
array
[
index
*
7
:])
return
{
channel
:
stats_from_buffer
(
array
[
index
*
9
:])
for
index
,
channel
in
enumerate
(
channels
)
if
channel
!=
-
1
}
...
...
tests/test_interface.py
View file @
8d4dc6ef
...
...
@@ -275,7 +275,7 @@ def test_get_module_statistics(interface):
m
=
interface
.
handel
.
xiaGetRunData
def
side_effect
(
channel
,
dtype
,
arg
):
arg
[
3
*
7
:
4
*
7
]
=
raw
arg
[
3
*
9
:
4
*
9
]
=
raw
return
0
raw
=
[
...
...
@@ -284,14 +284,16 @@ def test_get_module_statistics(interface):
255.
,
3088.
,
2742.
,
3131.
,
2721.
]
3131.720827046904
,
2721.350825353351
,
0.
,
0.
]
expected
=
{
8
:
interface
.
Stats
(
1.00758784
,
0.98603936
,
3088
.
,
2742
.
,
3088
,
2742
,
3131.720827046904
,
2721.350825353351
,
0.13103658479051494
)}
...
...
@@ -303,21 +305,16 @@ def test_get_module_statistics(interface):
assert
interface
.
get_module_statistics
(
'module3'
)
==
expected
m2
.
assert_called_once_with
(
'module3'
)
arg
=
m
.
call_args
[
0
][
2
]
m
.
assert_called_once_with
(
8
,
b
'module_statistics'
,
arg
)
# Second test
raw
[
6
]
=
1.23
# OCR inconsistency
with
pytest
.
raises
(
ValueError
)
as
ctx
:
interface
.
get_module_statistics
(
'module3'
)
assert
'OCR'
in
str
(
ctx
.
value
)
assert
'1.23'
in
str
(
ctx
.
value
)
assert
'2721.3508'
in
str
(
ctx
.
value
)
m
.
assert_called_once_with
(
8
,
b
'module_statistics_2'
,
arg
)
# Second test
raw
[
5
]
=
4.56
# ICR inconsistency
with
pytest
.
raises
(
ValueError
)
as
ctx
:
raw
[
6
]
=
1.23
# OCR inconsistency
with
pytest
.
warns
(
UserWarning
)
as
ctx
:
interface
.
get_module_statistics
(
'module3'
)
assert
'ICR'
in
str
(
ctx
.
value
)
assert
'4.56'
in
str
(
ctx
.
value
)
assert
'3131.7208'
in
str
(
ctx
.
value
)
assert
ctx
[
0
].
message
.
args
[
0
].
startswith
(
'ICR buffer inconsistency: 4.56 != 3131.7208'
)
assert
ctx
[
1
].
message
.
args
[
0
].
startswith
(
'OCR buffer inconsistency: 1.23 != 2721.3508'
)
# Make sure errors have been checked
interface
.
check_error
.
assert_called_with
(
0
)
...
...
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