Browse Source

Implemented test.

zolfa-add_slices_loading
Gabriele Girelli 4 years ago
parent
commit
08eca8966c
1 changed files with 17 additions and 8 deletions
  1. +17
    -8
      tests/test_reader.py

+ 17
- 8
tests/test_reader.py View File

@ -16,18 +16,27 @@ class TestReader(unittest.TestCase):
def test_extension(self):
self.assertTrue('nd2' in ND2Reader.class_exts())
def cmp_two_readers(self, r1, r2):
attributes = r1.data['image_attributes']['SLxImageAttributes']
self.assertEqual(r2.metadata['width'], attributes['uiWidth'])
self.assertEqual(r2.metadata['height'], attributes['uiHeight'])
self.assertEqual(r2.metadata['width'], r2.sizes['x'])
self.assertEqual(r2.metadata['height'], r2.sizes['y'])
self.assertEqual(r2.pixel_type, np.float64)
self.assertEqual(r2.iter_axes, ['t'])
def test_init_and_init_axes(self):
with ArtificialND2('test_data/test_nd2_reader.nd2') as artificial:
with ND2Reader('test_data/test_nd2_reader.nd2') as reader:
attributes = artificial.data['image_attributes']['SLxImageAttributes']
self.assertEqual(reader.metadata['width'], attributes['uiWidth'])
self.assertEqual(reader.metadata['height'], attributes['uiHeight'])
self.cmp_two_readers(artificial, reader)
self.assertEqual(reader.metadata['width'], reader.sizes['x'])
self.assertEqual(reader.metadata['height'], reader.sizes['y'])
self.assertEqual(reader.pixel_type, np.float64)
self.assertEqual(reader.iter_axes, ['t'])
def test_init_from_handler(self):
with ArtificialND2('test_data/test_nd2_reader.nd2') as artificial:
with open('test_data/test_nd2_reader.nd2', "rb") as FH:
with ND2Reader(FH) as reader:
self.cmp_two_readers(artificial, reader)
def test_init_empty_file(self):
with ArtificialND2('test_data/empty.nd2', skip_blocks=['label_map_marker']):


Loading…
Cancel
Save