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
tomoscan
Commits
39adf495
Commit
39adf495
authored
Mar 09, 2020
by
payno
Browse files
fix unit test before 0.2
parent
12c48f26
Pipeline
#22663
passed with stages
in 2 minutes and 1 second
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tomoscan/esrf/test/test_hdf5scan.py
View file @
39adf495
...
...
@@ -66,7 +66,7 @@ class TestHDF5Scan(HDF5TestBaseClass):
self
.
assertEqual
(
self
.
scan
.
master_file
,
self
.
dataset_file
)
self
.
assertEqual
(
self
.
scan
.
path
,
os
.
path
.
dirname
(
self
.
dataset_file
))
self
.
assertEqual
(
self
.
scan
.
type
,
'hdf5'
)
self
.
assertEqual
(
self
.
scan
.
entry
,
'
/
entry0000'
)
self
.
assertEqual
(
self
.
scan
.
entry
,
'entry0000'
)
self
.
assertEqual
(
len
(
self
.
scan
.
flats
),
42
)
self
.
assertEqual
(
len
(
self
.
scan
.
darks
),
1
)
self
.
assertEqual
(
len
(
self
.
scan
.
return_projs
),
3
)
...
...
@@ -99,7 +99,7 @@ class TestHDF5Scan(HDF5TestBaseClass):
numpy
.
isclose
(
proj_2
.
rotation_angle
,
0.24
)
self
.
assertFalse
(
proj_2
.
is_control
)
self
.
assertEqual
(
proj_2
.
url
.
file_path
(),
self
.
scan
.
master_file
)
self
.
assertEqual
(
proj_2
.
url
.
data_path
(),
'
/
entry0000/instrument/detector/data'
)
self
.
assertEqual
(
proj_2
.
url
.
data_path
(),
'entry0000/instrument/detector/data'
)
self
.
assertEqual
(
proj_2
.
url
.
data_slice
(),
24
)
self
.
assertEqual
(
proj_2
.
image_key
,
ImageKey
.
PROJECTION
)
self
.
assertEqual
(
get_data
(
proj_2
.
url
).
shape
,
(
20
,
20
))
...
...
@@ -116,7 +116,7 @@ class TestHDF5Scan(HDF5TestBaseClass):
numpy
.
isclose
(
dark_0
.
rotation_angle
,
0.0
)
self
.
assertFalse
(
dark_0
.
is_control
)
self
.
assertEqual
(
dark_0
.
url
.
file_path
(),
self
.
scan
.
master_file
)
self
.
assertEqual
(
dark_0
.
url
.
data_path
(),
'
/
entry0000/instrument/detector/data'
)
self
.
assertEqual
(
dark_0
.
url
.
data_path
(),
'entry0000/instrument/detector/data'
)
self
.
assertEqual
(
dark_0
.
url
.
data_slice
(),
0
)
self
.
assertEqual
(
dark_0
.
image_key
,
ImageKey
.
DARK_FIELD
)
self
.
assertEqual
(
get_data
(
dark_0
.
url
).
shape
,
(
20
,
20
))
...
...
@@ -128,7 +128,7 @@ class TestHDF5Scan(HDF5TestBaseClass):
self
.
assertFalse
(
ref_1
.
is_control
)
self
.
assertEqual
(
ref_1
.
url
.
file_path
(),
self
.
scan
.
master_file
)
self
.
assertEqual
(
ref_1
.
url
.
data_path
(),
'
/
entry0000/instrument/detector/data'
)
'entry0000/instrument/detector/data'
)
self
.
assertEqual
(
ref_1
.
url
.
data_slice
(),
2
)
self
.
assertEqual
(
ref_1
.
image_key
,
ImageKey
.
FLAT_FIELD
)
self
.
assertEqual
(
get_data
(
ref_1
.
url
).
shape
,
(
20
,
20
))
...
...
@@ -141,7 +141,7 @@ class TestHDF5Scan(HDF5TestBaseClass):
self
.
assertTrue
(
r_proj_0
.
is_control
)
self
.
assertEqual
(
r_proj_0
.
url
.
file_path
(),
self
.
scan
.
master_file
)
self
.
assertEqual
(
r_proj_0
.
url
.
data_path
(),
'
/
entry0000/instrument/detector/data'
)
'entry0000/instrument/detector/data'
)
self
.
assertEqual
(
r_proj_0
.
url
.
data_slice
(),
1543
)
self
.
assertEqual
(
r_proj_0
.
image_key
,
ImageKey
.
PROJECTION
)
self
.
assertEqual
(
get_data
(
r_proj_0
.
url
).
shape
,
(
20
,
20
))
...
...
@@ -183,19 +183,19 @@ class TestHDF5Scan(HDF5TestBaseClass):
self
.
assertEquals
(
len
(
radios_urls_evolution
),
1503
)
self
.
assertEquals
(
radios_urls_evolution
[
0
].
file_path
(),
self
.
scan
.
master_file
)
self
.
assertEquals
(
radios_urls_evolution
[
0
].
data_slice
(),
22
)
self
.
assertEquals
(
radios_urls_evolution
[
0
].
data_path
(),
'
/
entry0000/instrument/detector/data'
)
self
.
assertEquals
(
radios_urls_evolution
[
0
].
data_path
(),
'entry0000/instrument/detector/data'
)
def
testDarkRefUtils
(
self
):
self
.
assertEqual
(
self
.
scan
.
tomo_n
,
1500
)
pixel_size
=
self
.
scan
.
pixel_size
self
.
assertTrue
(
pixel_size
is
not
None
)
self
.
assertTrue
(
numpy
.
isclose
(
self
.
scan
.
pixel_size
,
0.05
*
metricsystem
.
MetricSystem
.
MI
LLI
METER
.
value
))
self
.
assertTrue
(
numpy
.
isclose
(
self
.
scan
.
get_pixel_size
(
unit
=
'm
m
'
),
0.05
))
0.05
*
metricsystem
.
MetricSystem
.
MI
CRO
METER
.
value
))
self
.
assertTrue
(
numpy
.
isclose
(
self
.
scan
.
get_pixel_size
(
unit
=
'm
icrometer
'
),
0.05
))
self
.
assertTrue
(
numpy
.
isclose
(
self
.
scan
.
x_pixel_size
,
0.05
*
metricsystem
.
MetricSystem
.
MI
LLI
METER
.
value
))
0.05
*
metricsystem
.
MetricSystem
.
MI
CRO
METER
.
value
))
self
.
assertTrue
(
numpy
.
isclose
(
self
.
scan
.
y_pixel_size
,
0.05
*
metricsystem
.
MetricSystem
.
MI
LLI
METER
.
value
))
0.05
*
metricsystem
.
MetricSystem
.
MI
CRO
METER
.
value
))
def
testNabuUtil
(
self
):
self
.
assertTrue
(
numpy
.
isclose
(
self
.
scan
.
distance
,
-
19.9735
))
...
...
tomoscan/test/test_factory.py
View file @
39adf495
...
...
@@ -34,7 +34,6 @@ from ..esrf.edfscan import EDFTomoScan
from
..esrf.hdf5scan
import
HDF5TomoScan
from
..scanfactory
import
ScanFactory
from
.utils
import
UtilsTest
from
silx.io.url
import
DataUrl
import
tempfile
...
...
@@ -65,7 +64,7 @@ class TestScanFactory(unittest.TestCase):
self
.
assertTrue
(
isinstance
(
scan
,
HDF5TomoScan
))
self
.
assertEqual
(
scan
.
path
,
os
.
path
.
dirname
(
master_file
))
self
.
assertEqual
(
scan
.
master_file
,
master_file
)
self
.
assertEqual
(
scan
.
entry
,
'
/
entry'
)
self
.
assertEqual
(
scan
.
entry
,
'entry'
)
def
test_one_two_nx
(
self
):
"""Can we create a TomoScanBase from a .nx master file containing
...
...
@@ -75,7 +74,7 @@ class TestScanFactory(unittest.TestCase):
self
.
assertTrue
(
isinstance
(
scan
,
HDF5TomoScan
))
self
.
assertEqual
(
scan
.
path
,
os
.
path
.
dirname
(
master_file
))
self
.
assertEqual
(
scan
.
master_file
,
master_file
)
self
.
assertEqual
(
scan
.
entry
,
'
/
entry0000'
)
self
.
assertEqual
(
scan
.
entry
,
'entry0000'
)
def
test_two_nx
(
self
):
"""Can we create two TomoScanBase from a .nx master file containing
...
...
@@ -83,7 +82,7 @@ class TestScanFactory(unittest.TestCase):
master_file
=
UtilsTest
.
getH5Dataset
(
'frm_edftomomill_twoentries.nx'
)
scans
=
ScanFactory
.
create_scan_objects
(
master_file
)
self
.
assertEqual
(
len
(
scans
),
2
)
for
scan
,
scan_entry
in
zip
(
scans
,
(
'
/
entry0000'
,
'
/
entry0001'
)):
for
scan
,
scan_entry
in
zip
(
scans
,
(
'entry0000'
,
'entry0001'
)):
self
.
assertTrue
(
isinstance
(
scan
,
HDF5TomoScan
))
self
.
assertEqual
(
scan
.
path
,
os
.
path
.
dirname
(
master_file
))
self
.
assertEqual
(
scan
.
master_file
,
master_file
)
...
...
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