Commit 39adf495 authored by payno's avatar payno
Browse files

fix unit test before 0.2

parent 12c48f26
Pipeline #22663 passed with stages
in 2 minutes and 1 second
...@@ -66,7 +66,7 @@ class TestHDF5Scan(HDF5TestBaseClass): ...@@ -66,7 +66,7 @@ class TestHDF5Scan(HDF5TestBaseClass):
self.assertEqual(self.scan.master_file, self.dataset_file) self.assertEqual(self.scan.master_file, self.dataset_file)
self.assertEqual(self.scan.path, os.path.dirname(self.dataset_file)) self.assertEqual(self.scan.path, os.path.dirname(self.dataset_file))
self.assertEqual(self.scan.type, 'hdf5') 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.flats), 42)
self.assertEqual(len(self.scan.darks), 1) self.assertEqual(len(self.scan.darks), 1)
self.assertEqual(len(self.scan.return_projs), 3) self.assertEqual(len(self.scan.return_projs), 3)
...@@ -99,7 +99,7 @@ class TestHDF5Scan(HDF5TestBaseClass): ...@@ -99,7 +99,7 @@ class TestHDF5Scan(HDF5TestBaseClass):
numpy.isclose(proj_2.rotation_angle, 0.24) numpy.isclose(proj_2.rotation_angle, 0.24)
self.assertFalse(proj_2.is_control) self.assertFalse(proj_2.is_control)
self.assertEqual(proj_2.url.file_path(), self.scan.master_file) 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.url.data_slice(), 24)
self.assertEqual(proj_2.image_key, ImageKey.PROJECTION) self.assertEqual(proj_2.image_key, ImageKey.PROJECTION)
self.assertEqual(get_data(proj_2.url).shape, (20, 20)) self.assertEqual(get_data(proj_2.url).shape, (20, 20))
...@@ -116,7 +116,7 @@ class TestHDF5Scan(HDF5TestBaseClass): ...@@ -116,7 +116,7 @@ class TestHDF5Scan(HDF5TestBaseClass):
numpy.isclose(dark_0.rotation_angle, 0.0) numpy.isclose(dark_0.rotation_angle, 0.0)
self.assertFalse(dark_0.is_control) self.assertFalse(dark_0.is_control)
self.assertEqual(dark_0.url.file_path(), self.scan.master_file) 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.url.data_slice(), 0)
self.assertEqual(dark_0.image_key, ImageKey.DARK_FIELD) self.assertEqual(dark_0.image_key, ImageKey.DARK_FIELD)
self.assertEqual(get_data(dark_0.url).shape, (20, 20)) self.assertEqual(get_data(dark_0.url).shape, (20, 20))
...@@ -128,7 +128,7 @@ class TestHDF5Scan(HDF5TestBaseClass): ...@@ -128,7 +128,7 @@ class TestHDF5Scan(HDF5TestBaseClass):
self.assertFalse(ref_1.is_control) self.assertFalse(ref_1.is_control)
self.assertEqual(ref_1.url.file_path(), self.scan.master_file) self.assertEqual(ref_1.url.file_path(), self.scan.master_file)
self.assertEqual(ref_1.url.data_path(), 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.url.data_slice(), 2)
self.assertEqual(ref_1.image_key, ImageKey.FLAT_FIELD) self.assertEqual(ref_1.image_key, ImageKey.FLAT_FIELD)
self.assertEqual(get_data(ref_1.url).shape, (20, 20)) self.assertEqual(get_data(ref_1.url).shape, (20, 20))
...@@ -141,7 +141,7 @@ class TestHDF5Scan(HDF5TestBaseClass): ...@@ -141,7 +141,7 @@ class TestHDF5Scan(HDF5TestBaseClass):
self.assertTrue(r_proj_0.is_control) 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.file_path(), self.scan.master_file)
self.assertEqual(r_proj_0.url.data_path(), 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.url.data_slice(), 1543)
self.assertEqual(r_proj_0.image_key, ImageKey.PROJECTION) self.assertEqual(r_proj_0.image_key, ImageKey.PROJECTION)
self.assertEqual(get_data(r_proj_0.url).shape, (20, 20)) self.assertEqual(get_data(r_proj_0.url).shape, (20, 20))
...@@ -183,19 +183,19 @@ class TestHDF5Scan(HDF5TestBaseClass): ...@@ -183,19 +183,19 @@ class TestHDF5Scan(HDF5TestBaseClass):
self.assertEquals(len(radios_urls_evolution), 1503) 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].file_path(), self.scan.master_file)
self.assertEquals(radios_urls_evolution[0].data_slice(), 22) 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): def testDarkRefUtils(self):
self.assertEqual(self.scan.tomo_n, 1500) self.assertEqual(self.scan.tomo_n, 1500)
pixel_size = self.scan.pixel_size pixel_size = self.scan.pixel_size
self.assertTrue(pixel_size is not None) self.assertTrue(pixel_size is not None)
self.assertTrue(numpy.isclose(self.scan.pixel_size, self.assertTrue(numpy.isclose(self.scan.pixel_size,
0.05 * metricsystem.MetricSystem.MILLIMETER.value)) 0.05 * metricsystem.MetricSystem.MICROMETER.value))
self.assertTrue(numpy.isclose(self.scan.get_pixel_size(unit='mm'), 0.05)) self.assertTrue(numpy.isclose(self.scan.get_pixel_size(unit='micrometer'), 0.05))
self.assertTrue(numpy.isclose(self.scan.x_pixel_size, self.assertTrue(numpy.isclose(self.scan.x_pixel_size,
0.05 * metricsystem.MetricSystem.MILLIMETER.value)) 0.05 * metricsystem.MetricSystem.MICROMETER.value))
self.assertTrue(numpy.isclose(self.scan.y_pixel_size, self.assertTrue(numpy.isclose(self.scan.y_pixel_size,
0.05 * metricsystem.MetricSystem.MILLIMETER.value)) 0.05 * metricsystem.MetricSystem.MICROMETER.value))
def testNabuUtil(self): def testNabuUtil(self):
self.assertTrue(numpy.isclose(self.scan.distance, -19.9735)) self.assertTrue(numpy.isclose(self.scan.distance, -19.9735))
......
...@@ -34,7 +34,6 @@ from ..esrf.edfscan import EDFTomoScan ...@@ -34,7 +34,6 @@ from ..esrf.edfscan import EDFTomoScan
from ..esrf.hdf5scan import HDF5TomoScan from ..esrf.hdf5scan import HDF5TomoScan
from ..scanfactory import ScanFactory from ..scanfactory import ScanFactory
from .utils import UtilsTest from .utils import UtilsTest
from silx.io.url import DataUrl
import tempfile import tempfile
...@@ -65,7 +64,7 @@ class TestScanFactory(unittest.TestCase): ...@@ -65,7 +64,7 @@ class TestScanFactory(unittest.TestCase):
self.assertTrue(isinstance(scan, HDF5TomoScan)) self.assertTrue(isinstance(scan, HDF5TomoScan))
self.assertEqual(scan.path, os.path.dirname(master_file)) self.assertEqual(scan.path, os.path.dirname(master_file))
self.assertEqual(scan.master_file, 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): def test_one_two_nx(self):
"""Can we create a TomoScanBase from a .nx master file containing """Can we create a TomoScanBase from a .nx master file containing
...@@ -75,7 +74,7 @@ class TestScanFactory(unittest.TestCase): ...@@ -75,7 +74,7 @@ class TestScanFactory(unittest.TestCase):
self.assertTrue(isinstance(scan, HDF5TomoScan)) self.assertTrue(isinstance(scan, HDF5TomoScan))
self.assertEqual(scan.path, os.path.dirname(master_file)) self.assertEqual(scan.path, os.path.dirname(master_file))
self.assertEqual(scan.master_file, master_file) self.assertEqual(scan.master_file, master_file)
self.assertEqual(scan.entry, '/entry0000') self.assertEqual(scan.entry, 'entry0000')
def test_two_nx(self): def test_two_nx(self):
"""Can we create two TomoScanBase from a .nx master file containing """Can we create two TomoScanBase from a .nx master file containing
...@@ -83,7 +82,7 @@ class TestScanFactory(unittest.TestCase): ...@@ -83,7 +82,7 @@ class TestScanFactory(unittest.TestCase):
master_file = UtilsTest.getH5Dataset('frm_edftomomill_twoentries.nx') master_file = UtilsTest.getH5Dataset('frm_edftomomill_twoentries.nx')
scans = ScanFactory.create_scan_objects(master_file) scans = ScanFactory.create_scan_objects(master_file)
self.assertEqual(len(scans), 2) 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.assertTrue(isinstance(scan, HDF5TomoScan))
self.assertEqual(scan.path, os.path.dirname(master_file)) self.assertEqual(scan.path, os.path.dirname(master_file))
self.assertEqual(scan.master_file, master_file) self.assertEqual(scan.master_file, master_file)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment