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
623c75e2
Commit
623c75e2
authored
2 years ago
by
Karim Ahmed
Browse files
Options
Downloads
Patches
Plain Diff
add tests for gotthard2alg
parent
37360914
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!658
[Gotthard-II] Correction
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitlab-ci.yml
+1
-1
1 addition, 1 deletion
.gitlab-ci.yml
tests/test_cythonalgs.py
+1
-0
1 addition, 0 deletions
tests/test_cythonalgs.py
tests/test_gotthard2algs.py
+61
-0
61 additions, 0 deletions
tests/test_gotthard2algs.py
with
63 additions
and
1 deletion
.gitlab-ci.yml
+
1
−
1
View file @
623c75e2
...
@@ -57,4 +57,4 @@ cython-editable-install-test:
...
@@ -57,4 +57,4 @@ cython-editable-install-test:
<<
:
*before_script
<<
:
*before_script
script
:
script
:
-
python3 -m pip install -e ".[test]"
-
python3 -m pip install -e ".[test]"
-
python3 -m pytest --color yes --verbose ./tests/test_
agipd
algs.py
-
python3 -m pytest --color yes --verbose ./tests/test_
cython
algs.py
This diff is collapsed.
Click to expand it.
tests/test_
agipd
algs.py
→
tests/test_
cython
algs.py
+
1
−
0
View file @
623c75e2
def
test_import
():
def
test_import
():
from
cal_tools
import
agipdalgs
# noqa
from
cal_tools
import
agipdalgs
# noqa
from
cal_tools
import
gotthard2algs
# noqa
This diff is collapsed.
Click to expand it.
tests/test_gotthard2algs.py
0 → 100644
+
61
−
0
View file @
623c75e2
import
numpy
as
np
import
pytest
from
cal_tools.gotthard2algs
import
convert_to_10bit
,
correct_train
def
test_convert_to_10bit
():
n_stripes
=
10
n_pulses
=
500
# Define LUT, raw data 12 bit, and raw data 10bit array.
lut
=
np
.
array
(
[[
list
(
range
(
4096
//
2
))
*
2
,
list
(
range
(
4096
//
2
,
4096
))
*
2
]]
*
n_stripes
,
dtype
=
np
.
uint16
)
raw_data
=
np
.
array
([
list
(
range
(
n_stripes
))]
*
n_pulses
,
dtype
=
np
.
uint16
)
raw_data10bit
=
np
.
zeros
(
raw_data
.
shape
,
dtype
=
np
.
float32
)
result
=
np
.
concatenate
(
[
np
.
array
(
x
)[:,
None
]
for
x
in
[
list
(
range
(
n_stripes
)),
list
(
range
(
2048
,
2048
+
n_stripes
))
]
*
(
n_pulses
//
2
)],
axis
=
1
,
dtype
=
np
.
float32
,
).
T
convert_to_10bit
(
raw_data
,
lut
.
astype
(
np
.
uint16
),
raw_data10bit
)
assert
np
.
allclose
(
result
,
raw_data10bit
)
@pytest.mark.parametrize
(
"
gain_corr
"
,
[
True
,
False
])
def
test_correct_train
(
gain_corr
):
raw_d
=
np
.
random
.
randn
(
2700
,
1280
).
astype
(
np
.
float32
)
gain
=
np
.
random
.
choice
([
0
,
1
,
2
],
size
=
(
2700
,
1280
)).
astype
(
np
.
uint8
)
offset
=
np
.
random
.
randn
(
1280
,
2
,
3
).
astype
(
np
.
float32
)
relgain
=
np
.
random
.
randn
(
1280
,
2
,
3
).
astype
(
np
.
float32
)
badpixles
=
np
.
zeros_like
(
offset
).
astype
(
np
.
uint32
).
astype
(
np
.
uint32
)
test_data
=
raw_d
.
copy
()
mask
=
np
.
zeros_like
(
test_data
).
astype
(
np
.
uint32
)
correct_train
(
test_data
,
mask
,
gain
,
offset
,
relgain
,
badpixles
,
gain_corr
)
ref_data
=
raw_d
.
copy
()
ref_data
[::
2
,
:]
-=
np
.
choose
(
gain
[::
2
,
:],
np
.
moveaxis
(
offset
[:,
0
,
:],
1
,
0
))
ref_data
[
1
::
2
,
:]
-=
np
.
choose
(
gain
[
1
::
2
,
:],
np
.
moveaxis
(
offset
[:,
1
,
:],
1
,
0
))
if
gain_corr
:
ref_data
[::
2
,
:]
/=
np
.
choose
(
gain
[::
2
,
:],
np
.
moveaxis
(
relgain
[:,
0
,
:],
1
,
0
))
ref_data
[
1
::
2
,
:]
/=
np
.
choose
(
gain
[
1
::
2
,
:],
np
.
moveaxis
(
relgain
[:,
1
,
:],
1
,
0
))
assert
np
.
allclose
(
test_data
,
test_data
)
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