Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tomotools
Nabu
Commits
9207974f
Commit
9207974f
authored
Sep 11, 2020
by
Pierre Paleo
Browse files
Add unit test for sino normalization
parent
80f835e1
Pipeline
#33317
passed with stages
in 1 minute and 55 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
nabu/preproc/tests/test_sino_normalization.py
0 → 100644
View file @
9207974f
import
os.path
as
path
import
numpy
as
np
import
pytest
from
nabu.testutils
import
get_data
from
nabu.cuda.utils
import
__has_pycuda__
from
nabu.preproc.sinogram
import
SinoNormalization
if
__has_pycuda__
:
from
nabu.preproc.sinogram_cuda
import
CudaSinoNormalization
import
pycuda.gpuarray
as
garray
@
pytest
.
fixture
(
scope
=
"class"
)
def
bootstrap
(
request
):
cls
=
request
.
cls
cls
.
sino
=
get_data
(
"sino_refill.npy"
)
cls
.
tol
=
1e-7
@
pytest
.
mark
.
usefixtures
(
"bootstrap"
)
class
TestSinoNormalization
:
def
test_sino_normalization
(
self
):
sino_proc
=
SinoNormalization
(
kind
=
"chebyshev"
,
sinos_shape
=
self
.
sino
.
shape
)
sino
=
self
.
sino
.
copy
()
sino_proc
.
normalize
(
sino
)
@
pytest
.
mark
.
skipif
(
not
(
__has_pycuda__
),
reason
=
"Need pycuda for sinogram normalization with cuda backend"
)
def
test_dff_cuda
(
self
):
import
pycuda.autoinit
sino_proc
=
SinoNormalization
(
kind
=
"chebyshev"
,
sinos_shape
=
self
.
sino
.
shape
)
sino
=
self
.
sino
.
copy
()
ref
=
sino_proc
.
normalize
(
sino
)
cuda_sino_proc
=
CudaSinoNormalization
(
kind
=
"chebyshev"
,
sinos_shape
=
self
.
sino
.
shape
)
d_sino
=
garray
.
to_gpu
(
self
.
sino
)
cuda_sino_proc
.
normalize
(
d_sino
)
res
=
d_sino
.
get
()
assert
np
.
max
(
np
.
abs
(
res
-
ref
))
<
self
.
tol
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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