Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor 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
calibration
pycalibration
Commits
52a1c748
Commit
52a1c748
authored
3 years ago
by
Cyril Danilevski
Browse files
Options
Downloads
Patches
Plain Diff
Add test for module_index_to_qm
parent
e894d0bd
No related branches found
No related tags found
1 merge request
!438
Feat/agipd add fixed gain mode to dark notebook
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cal_tools/cal_tools/enums.py
+3
-3
3 additions, 3 deletions
cal_tools/cal_tools/enums.py
cal_tools/cal_tools/tools.py
+1
-0
1 addition, 0 deletions
cal_tools/cal_tools/tools.py
tests/test_cal_tools.py
+17
-1
17 additions, 1 deletion
tests/test_cal_tools.py
with
21 additions
and
4 deletions
cal_tools/cal_tools/enums.py
+
3
−
3
View file @
52a1c748
...
...
@@ -51,9 +51,9 @@ class SnowResolution(Enum):
class
AgipdGainMode
(
IntEnum
):
"""
Encoding added to distinguish between adaptive and fixed gain
"""
"""
Gain Modes where the values is 0 if Adaptive, or High/Medium/Low.
"""
ADAPTIVE_GAIN
=
0
# adaptive is default (if gain mode missing in slow data)
FIXED_HIGH_GAIN
=
1
# non-zero means fixed gain
ADAPTIVE_GAIN
=
0
FIXED_HIGH_GAIN
=
1
FIXED_MEDIUM_GAIN
=
2
FIXED_LOW_GAIN
=
3
This diff is collapsed.
Click to expand it.
cal_tools/cal_tools/tools.py
+
1
−
0
View file @
52a1c748
...
...
@@ -675,6 +675,7 @@ def get_constant_from_db_and_time(karabo_id: str, karabo_da: str,
def
module_index_to_qm
(
index
:
int
,
total_modules
:
int
=
16
):
"""
Maps module index (0-indexed) to quadrant + module string (1-indexed)
"""
assert
index
<
total_modules
,
f
'
{
index
}
is greater than
{
total_modules
}
'
modules_per_quad
=
total_modules
//
4
quad
,
mod
=
divmod
(
index
,
modules_per_quad
)
return
f
"
Q
{
quad
+
1
}
M
{
mod
+
1
}
"
...
...
This diff is collapsed.
Click to expand it.
tests/test_cal_tools.py
+
17
−
1
View file @
52a1c748
...
...
@@ -3,7 +3,7 @@ from pathlib import Path
import
pytest
from
cal_tools.plotting
import
show_processed_modules
from
cal_tools.tools
import
get_dir_creation_date
from
cal_tools.tools
import
get_dir_creation_date
,
module_index_to_qm
def
test_show_processed_modules
():
...
...
@@ -30,3 +30,19 @@ def test_dir_creation_date():
date
=
get_dir_creation_date
(
folder
,
9999
)
assert
isinstance
(
date
,
datetime
)
assert
str
(
date
)
==
'
2019-12-16 08:52:25.196603
'
def
test_module_index_to_qm
():
assert
module_index_to_qm
(
0
)
==
'
Q1M1
'
assert
module_index_to_qm
(
1
)
==
'
Q1M2
'
assert
module_index_to_qm
(
4
)
==
'
Q2M1
'
assert
module_index_to_qm
(
6
)
==
'
Q2M3
'
assert
module_index_to_qm
(
4
,
5
)
==
'
Q5M1
'
with
pytest
.
raises
(
AssertionError
):
module_index_to_qm
(
18
)
with
pytest
.
raises
(
AssertionError
):
module_index_to_qm
(
7
,
5
)
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