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
nxtomomill
Commits
3b2352e0
Commit
3b2352e0
authored
Nov 30, 2021
by
payno
Browse files
Merge branch 'benefit_from_validator' into 'master'
benefit from validator and improve tests See merge request
!81
parents
0e1ce57f
4ce926d4
Pipeline
#60804
passed with stages
in 6 minutes and 25 seconds
Changes
5
Pipelines
2
Show whitespace changes
Inline
Side-by-side
nxtomomill/app/test/test_patch_nx_app.py
View file @
3b2352e0
...
@@ -54,8 +54,8 @@ def test_patch_nx_application():
...
@@ -54,8 +54,8 @@ def test_patch_nx_application():
n_proj
=
nproj
,
n_proj
=
nproj
,
n_ini_proj
=
nproj
,
n_ini_proj
=
nproj
,
create_ini_dark
=
False
,
create_ini_dark
=
False
,
create_ini_
ref
=
False
,
create_ini_
flat
=
False
,
create_final_
ref
=
False
,
create_final_
flat
=
False
,
dim
=
dim
,
dim
=
dim
,
).
scan
).
scan
main
(
main
(
...
...
nxtomomill/converter/dxfile/test_dxfile.py
View file @
3b2352e0
...
@@ -37,6 +37,7 @@ from nxtomomill import converter
...
@@ -37,6 +37,7 @@ from nxtomomill import converter
from
tomoscan.esrf.hdf5scan
import
HDF5TomoScan
from
tomoscan.esrf.hdf5scan
import
HDF5TomoScan
from
nxtomomill.test.utils.dxfile
import
MockDxFile
from
nxtomomill.test.utils.dxfile
import
MockDxFile
from
silx.io.utils
import
get_data
from
silx.io.utils
import
get_data
from
tomoscan.validator
import
is_valid_for_reconstruction
class
TestDxToNxConverter
(
unittest
.
TestCase
):
class
TestDxToNxConverter
(
unittest
.
TestCase
):
...
@@ -83,6 +84,7 @@ class TestDxToNxConverter(unittest.TestCase):
...
@@ -83,6 +84,7 @@ class TestDxToNxConverter(unittest.TestCase):
self
.
assertEqual
(
len
(
scan
.
flats
),
self
.
n_flats
)
self
.
assertEqual
(
len
(
scan
.
flats
),
self
.
n_flats
)
self
.
assertEqual
(
numpy
.
array
(
scan
.
rotation_angle
).
min
(),
0
)
self
.
assertEqual
(
numpy
.
array
(
scan
.
rotation_angle
).
min
(),
0
)
self
.
assertEqual
(
numpy
.
array
(
scan
.
rotation_angle
).
max
(),
180
)
self
.
assertEqual
(
numpy
.
array
(
scan
.
rotation_angle
).
max
(),
180
)
assert
is_valid_for_reconstruction
(
scan
)
# check arrays are correctly copied from mock
# check arrays are correctly copied from mock
numpy
.
testing
.
assert_array_equal
(
numpy
.
testing
.
assert_array_equal
(
...
...
nxtomomill/converter/edf/test/test_edf2nx.py
View file @
3b2352e0
...
@@ -36,6 +36,7 @@ from tomoscan.esrf.mock import MockEDF
...
@@ -36,6 +36,7 @@ from tomoscan.esrf.mock import MockEDF
from
tomoscan.esrf.hdf5scan
import
HDF5TomoScan
from
tomoscan.esrf.hdf5scan
import
HDF5TomoScan
from
tomoscan.esrf.edfscan
import
EDFTomoScan
from
tomoscan.esrf.edfscan
import
EDFTomoScan
from
tomoscan
import
version
from
tomoscan
import
version
from
tomoscan.validator
import
is_valid_for_reconstruction
from
nxtomomill.utils
import
Progress
from
nxtomomill.utils
import
Progress
import
pytest
import
pytest
...
@@ -75,3 +76,4 @@ def test_edf_to_nx_converter(progress):
...
@@ -75,3 +76,4 @@ def test_edf_to_nx_converter(progress):
assert
len
(
hdf5_scan
.
alignment_projections
)
==
n_alignment_proj
assert
len
(
hdf5_scan
.
alignment_projections
)
==
n_alignment_proj
assert
hdf5_scan
.
dim_1
==
dim
assert
hdf5_scan
.
dim_1
==
dim
assert
hdf5_scan
.
dim_2
==
dim
assert
hdf5_scan
.
dim_2
==
dim
assert
is_valid_for_reconstruction
(
hdf5_scan
)
nxtomomill/converter/hdf5/test/test_hdf5converter.py
View file @
3b2352e0
...
@@ -41,6 +41,7 @@ from nxtomomill.converter.hdf5.acquisition.baseacquisition import EntryReader
...
@@ -41,6 +41,7 @@ from nxtomomill.converter.hdf5.acquisition.baseacquisition import EntryReader
from
nxtomomill.converter.hdf5.acquisition.baseacquisition
import
DatasetReader
from
nxtomomill.converter.hdf5.acquisition.baseacquisition
import
DatasetReader
from
nxtomomill.io.config
import
TomoHDF5Config
from
nxtomomill.io.config
import
TomoHDF5Config
from
tomoscan.esrf.hdf5scan
import
HDF5TomoScan
from
tomoscan.esrf.hdf5scan
import
HDF5TomoScan
from
tomoscan.validator
import
is_valid_for_reconstruction
from
nxtomomill.test.utils.bliss
import
MockBlissAcquisition
from
nxtomomill.test.utils.bliss
import
MockBlissAcquisition
from
silx.io.url
import
DataUrl
from
silx.io.url
import
DataUrl
from
silx.io.utils
import
get_data
from
silx.io.utils
import
get_data
...
@@ -70,11 +71,13 @@ def url_has_been_copied(file_path: str, url: DataUrl):
...
@@ -70,11 +71,13 @@ def url_has_been_copied(file_path: str, url: DataUrl):
class
TestH5ToNxConverter
(
unittest
.
TestCase
):
class
TestH5ToNxConverter
(
unittest
.
TestCase
):
def
setUp
(
self
)
->
None
:
def
setUp
(
self
)
->
None
:
super
().
setUp
()
self
.
folder
=
tempfile
.
mkdtemp
()
self
.
folder
=
tempfile
.
mkdtemp
()
self
.
config
=
TomoHDF5Config
()
self
.
config
=
TomoHDF5Config
()
def
tearDown
(
self
)
->
None
:
def
tearDown
(
self
)
->
None
:
shutil
.
rmtree
(
self
.
folder
)
shutil
.
rmtree
(
self
.
folder
)
super
().
tearDown
()
def
test_simple_converter_with_nx_detector_attr
(
self
):
def
test_simple_converter_with_nx_detector_attr
(
self
):
"""
"""
...
@@ -286,6 +289,7 @@ class TestH5ToNxConverter(unittest.TestCase):
...
@@ -286,6 +289,7 @@ class TestH5ToNxConverter(unittest.TestCase):
scan
=
HDF5TomoScan
(
scan
=
res_tuple
[
0
],
entry
=
res_tuple
[
1
])
scan
=
HDF5TomoScan
(
scan
=
res_tuple
[
0
],
entry
=
res_tuple
[
1
])
if
hasattr
(
scan
,
"z_translation"
):
if
hasattr
(
scan
,
"z_translation"
):
self
.
assertTrue
(
scan
.
z_translation
is
not
None
)
self
.
assertTrue
(
scan
.
z_translation
is
not
None
)
self
.
assertTrue
(
is_valid_for_reconstruction
(
scan
))
def
test_ignore_sub_entries
(
self
):
def
test_ignore_sub_entries
(
self
):
"""
"""
...
@@ -389,12 +393,14 @@ class TestDetectorDetection(unittest.TestCase):
...
@@ -389,12 +393,14 @@ class TestDetectorDetection(unittest.TestCase):
class
TestXRDCTConversion
(
unittest
.
TestCase
):
class
TestXRDCTConversion
(
unittest
.
TestCase
):
def
setUp
(
self
)
->
None
:
def
setUp
(
self
)
->
None
:
super
().
setUp
()
self
.
folder
=
tempfile
.
mkdtemp
()
self
.
folder
=
tempfile
.
mkdtemp
()
self
.
config
=
TomoHDF5Config
()
self
.
config
=
TomoHDF5Config
()
self
.
config
.
format
=
Format
.
XRD_CT
self
.
config
.
format
=
Format
.
XRD_CT
def
tearDown
(
self
)
->
None
:
def
tearDown
(
self
)
->
None
:
shutil
.
rmtree
(
self
.
folder
)
shutil
.
rmtree
(
self
.
folder
)
super
().
tearDown
()
def
test_simple_converter_with_nx_detector_attr
(
self
):
def
test_simple_converter_with_nx_detector_attr
(
self
):
"""
"""
...
@@ -442,6 +448,7 @@ class TestStandardAcqConversionWithExternalUrls(unittest.TestCase):
...
@@ -442,6 +448,7 @@ class TestStandardAcqConversionWithExternalUrls(unittest.TestCase):
"""Test conversion when frames are provided from urls"""
"""Test conversion when frames are provided from urls"""
def
setUp
(
self
)
->
None
:
def
setUp
(
self
)
->
None
:
super
().
setUp
()
self
.
folder
=
tempfile
.
mkdtemp
()
self
.
folder
=
tempfile
.
mkdtemp
()
self
.
config
=
TomoHDF5Config
()
self
.
config
=
TomoHDF5Config
()
self
.
config
.
output_file
=
os
.
path
.
join
(
self
.
folder
,
"output.nx"
)
self
.
config
.
output_file
=
os
.
path
.
join
(
self
.
folder
,
"output.nx"
)
...
@@ -468,6 +475,7 @@ class TestStandardAcqConversionWithExternalUrls(unittest.TestCase):
...
@@ -468,6 +475,7 @@ class TestStandardAcqConversionWithExternalUrls(unittest.TestCase):
def
tearDown
(
self
)
->
None
:
def
tearDown
(
self
)
->
None
:
shutil
.
rmtree
(
self
.
folder
)
shutil
.
rmtree
(
self
.
folder
)
super
().
tearDown
()
def
test_dataset_1
(
self
):
def
test_dataset_1
(
self
):
"""test a conversion where projections are contained in the
"""test a conversion where projections are contained in the
...
@@ -497,18 +505,20 @@ class TestStandardAcqConversionWithExternalUrls(unittest.TestCase):
...
@@ -497,18 +505,20 @@ class TestStandardAcqConversionWithExternalUrls(unittest.TestCase):
url
=
DataUrl
(
file_path
=
dark_flat_file
,
data_path
=
"/3.1"
,
scheme
=
"silx"
),
url
=
DataUrl
(
file_path
=
dark_flat_file
,
data_path
=
"/3.1"
,
scheme
=
"silx"
),
),
),
)
)
converter
.
from_h5_to_nx
(
converter
.
from_h5_to_nx
(
configuration
=
self
.
config
,
configuration
=
self
.
config
,
)
)
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
config
.
output_file
))
self
.
assertTrue
(
os
.
path
.
exists
(
self
.
config
.
output_file
),
"output file does not exists"
)
with
h5py
.
File
(
self
.
config
.
output_file
,
mode
=
"r"
)
as
h5s
:
with
h5py
.
File
(
self
.
config
.
output_file
,
mode
=
"r"
)
as
h5s
:
self
.
assertEqual
(
len
(
h5s
.
items
()),
1
)
self
.
assertEqual
(
len
(
h5s
.
items
()),
1
)
self
.
assertTrue
(
"entry0000"
in
h5s
)
self
.
assertTrue
(
"entry0000"
in
h5s
)
scan
=
HDF5TomoScan
(
scan
=
self
.
config
.
output_file
,
entry
=
"entry0000"
)
scan
=
HDF5TomoScan
(
scan
=
self
.
config
.
output_file
,
entry
=
"entry0000"
)
self
.
assertTrue
(
is_valid_for_reconstruction
(
scan
))
# check the `data`has been created
# check the `data`has been created
self
.
assertTrue
(
len
(
scan
.
projections
),
20
)
self
.
assertTrue
(
len
(
scan
.
projections
),
20
)
...
@@ -603,6 +613,7 @@ class TestStandardAcqConversionWithExternalUrls(unittest.TestCase):
...
@@ -603,6 +613,7 @@ class TestStandardAcqConversionWithExternalUrls(unittest.TestCase):
self
.
assertEqual
(
vs
.
file_name
,
"acqui_1/sample_0/sample_0.h5"
)
self
.
assertEqual
(
vs
.
file_name
,
"acqui_1/sample_0/sample_0.h5"
)
scan
=
HDF5TomoScan
(
scan
=
self
.
config
.
output_file
,
entry
=
"entry0000"
)
scan
=
HDF5TomoScan
(
scan
=
self
.
config
.
output_file
,
entry
=
"entry0000"
)
self
.
assertTrue
(
is_valid_for_reconstruction
(
scan
))
# check the `data`has been created
# check the `data`has been created
self
.
assertTrue
(
len
(
scan
.
projections
),
40
)
self
.
assertTrue
(
len
(
scan
.
projections
),
40
)
...
@@ -703,6 +714,7 @@ class TestZSeriesConversionWithExternalUrls(unittest.TestCase):
...
@@ -703,6 +714,7 @@ class TestZSeriesConversionWithExternalUrls(unittest.TestCase):
"""
"""
def
setUp
(
self
)
->
None
:
def
setUp
(
self
)
->
None
:
super
().
setUp
()
self
.
folder
=
tempfile
.
mkdtemp
()
self
.
folder
=
tempfile
.
mkdtemp
()
self
.
config
=
TomoHDF5Config
()
self
.
config
=
TomoHDF5Config
()
...
@@ -739,6 +751,7 @@ class TestZSeriesConversionWithExternalUrls(unittest.TestCase):
...
@@ -739,6 +751,7 @@ class TestZSeriesConversionWithExternalUrls(unittest.TestCase):
def
tearDown
(
self
)
->
None
:
def
tearDown
(
self
)
->
None
:
shutil
.
rmtree
(
self
.
folder
)
shutil
.
rmtree
(
self
.
folder
)
super
().
tearDown
()
def
test_dataset_zseries
(
self
):
def
test_dataset_zseries
(
self
):
"""Test a zseries with only external scan entries"""
"""Test a zseries with only external scan entries"""
...
...
nxtomomill/test/test_utils.py
View file @
3b2352e0
...
@@ -58,8 +58,8 @@ class BaseTestAddDarkAndFlats(unittest.TestCase):
...
@@ -58,8 +58,8 @@ class BaseTestAddDarkAndFlats(unittest.TestCase):
n_proj
=
self
.
nproj
,
n_proj
=
self
.
nproj
,
n_ini_proj
=
self
.
nproj
,
n_ini_proj
=
self
.
nproj
,
create_ini_dark
=
False
,
create_ini_dark
=
False
,
create_ini_
ref
=
False
,
create_ini_
flat
=
False
,
create_final_
ref
=
False
,
create_final_
flat
=
False
,
dim
=
self
.
dim
,
dim
=
self
.
dim
,
).
scan
).
scan
with
h5py
.
File
(
self
.
_simple_nx
.
master_file
,
mode
=
"r"
)
as
h5s
:
with
h5py
.
File
(
self
.
_simple_nx
.
master_file
,
mode
=
"r"
)
as
h5s
:
...
@@ -73,8 +73,8 @@ class BaseTestAddDarkAndFlats(unittest.TestCase):
...
@@ -73,8 +73,8 @@ class BaseTestAddDarkAndFlats(unittest.TestCase):
n_proj
=
0
,
n_proj
=
0
,
n_ini_proj
=
0
,
n_ini_proj
=
0
,
create_ini_dark
=
False
,
create_ini_dark
=
False
,
create_ini_
ref
=
False
,
create_ini_
flat
=
False
,
create_final_
ref
=
False
,
create_final_
flat
=
False
,
dim
=
self
.
dim
,
dim
=
self
.
dim
,
).
scan
).
scan
self
.
_create_vds
(
self
.
_create_vds
(
...
@@ -94,8 +94,8 @@ class BaseTestAddDarkAndFlats(unittest.TestCase):
...
@@ -94,8 +94,8 @@ class BaseTestAddDarkAndFlats(unittest.TestCase):
n_proj
=
0
,
n_proj
=
0
,
n_ini_proj
=
0
,
n_ini_proj
=
0
,
create_ini_dark
=
False
,
create_ini_dark
=
False
,
create_ini_
ref
=
False
,
create_ini_
flat
=
False
,
create_final_
ref
=
False
,
create_final_
flat
=
False
,
dim
=
self
.
dim
,
dim
=
self
.
dim
,
).
scan
).
scan
self
.
_create_vds
(
self
.
_create_vds
(
...
@@ -852,8 +852,8 @@ class TestChangeImageKeyControl(unittest.TestCase):
...
@@ -852,8 +852,8 @@ class TestChangeImageKeyControl(unittest.TestCase):
n_proj
=
self
.
nproj
,
n_proj
=
self
.
nproj
,
n_ini_proj
=
self
.
nproj
,
n_ini_proj
=
self
.
nproj
,
create_ini_dark
=
True
,
create_ini_dark
=
True
,
create_ini_
ref
=
True
,
create_ini_
flat
=
True
,
create_final_
ref
=
True
,
create_final_
flat
=
True
,
dim
=
self
.
dim
,
dim
=
self
.
dim
,
n_refs
=
4
,
n_refs
=
4
,
)
)
...
@@ -1096,8 +1096,8 @@ class TestAddDarkAndFlatFromADifferentFolderWithVDS(unittest.TestCase):
...
@@ -1096,8 +1096,8 @@ class TestAddDarkAndFlatFromADifferentFolderWithVDS(unittest.TestCase):
n_proj
=
10
,
n_proj
=
10
,
n_ini_proj
=
2
,
n_ini_proj
=
2
,
create_ini_dark
=
False
,
create_ini_dark
=
False
,
create_ini_
ref
=
False
,
create_ini_
flat
=
False
,
create_final_
ref
=
False
,
create_final_
flat
=
False
,
dim
=
self
.
dim
,
dim
=
self
.
dim
,
).
scan
).
scan
# 1. add first level of indirection for dark and flat and check the VDS
# 1. add first level of indirection for dark and flat and check the VDS
...
@@ -1123,8 +1123,8 @@ class TestAddDarkAndFlatFromADifferentFolderWithVDS(unittest.TestCase):
...
@@ -1123,8 +1123,8 @@ class TestAddDarkAndFlatFromADifferentFolderWithVDS(unittest.TestCase):
n_proj
=
10
,
n_proj
=
10
,
n_ini_proj
=
2
,
n_ini_proj
=
2
,
create_ini_dark
=
False
,
create_ini_dark
=
False
,
create_ini_
ref
=
False
,
create_ini_
flat
=
False
,
create_final_
ref
=
False
,
create_final_
flat
=
False
,
dim
=
self
.
dim
,
dim
=
self
.
dim
,
).
scan
).
scan
# 2. create a second level of indirection for dark and flat and check
# 2. create a second level of indirection for dark and flat and check
...
...
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