Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tomotools
Nabu
Commits
4bb98441
Commit
4bb98441
authored
Jun 09, 2020
by
Pierre Paleo
Browse files
Add test_double_flatfield for cuda backend
parent
36db2fcc
Pipeline
#26950
failed with stages
in 1 minute and 1 second
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nabu/preproc/tests/test_double_flatfield.py
View file @
4bb98441
...
...
@@ -7,7 +7,10 @@ from silx.io.url import DataUrl
from
tomoscan.esrf.mock
import
MockHDF5
from
nabu.io.reader
import
HDF5Reader
from
nabu.preproc.double_flatfield
import
DoubleFlatField
,
__have_scipy__
from
nabu.preproc.double_flatfield_cuda
import
CudaDoubleFlatField
,
__has_pycuda__
if
__has_pycuda__
:
import
pycuda.gpuarray
as
garray
@
pytest
.
fixture
(
scope
=
"class"
)
def
bootstrap
(
request
):
...
...
@@ -35,7 +38,10 @@ def bootstrap(request):
file_path
=
path
.
join
(
cls
.
dname
,
"dff.h5"
),
data_path
=
"/entry/double_flatfield/results/data"
)
cls
.
ff_cuda_dump_url
=
DataUrl
(
file_path
=
path
.
join
(
cls
.
dname
,
"dff_cuda.h5"
),
data_path
=
"/entry/double_flatfield/results/data"
)
golden
=
0
for
i
in
range
(
10
):
golden
+=
exp
(
-
i
)
...
...
@@ -64,3 +70,26 @@ class TestDoubleFlatField:
assert
np
.
max
(
np
.
abs
(
mydf2
-
mydf
))
<
self
.
tol
assert
np
.
max
(
np
.
abs
(
mydf
-
self
.
golden
))
<
self
.
tol
@
pytest
.
mark
.
skipif
(
not
(
__has_pycuda__
),
reason
=
"Need pycuda for double flatfield with cuda backend"
)
def
test_dff_cuda
(
self
):
import
pycuda.autoinit
dff
=
CudaDoubleFlatField
(
self
.
radios
.
shape
,
result_url
=
self
.
ff_cuda_dump_url
)
d_radios
=
garray
.
to_gpu
(
self
.
radios
)
mydf
=
dff
.
get_double_flatfield
(
radios
=
d_radios
).
get
()
assert
path
.
isfile
(
dff
.
result_url
.
file_path
())
dff2
=
CudaDoubleFlatField
(
self
.
radios
.
shape
,
result_url
=
self
.
ff_cuda_dump_url
)
mydf2
=
dff2
.
get_double_flatfield
(
radios
=
d_radios
).
get
()
assert
np
.
max
(
np
.
abs
(
mydf2
-
mydf
))
<
self
.
tol
assert
np
.
max
(
np
.
abs
(
mydf
-
self
.
golden
))
<
self
.
tol
Write
Preview
Supports
Markdown
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