You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.3 KiB

8 years ago
  1. import unittest
  2. import numpy as np
  3. from nd2reader.artificial import ArtificialND2
  4. from nd2reader.exceptions import EmptyFileError
  5. from nd2reader.reader import ND2Reader
  6. class TestReader(unittest.TestCase):
  7. def test_extension(self):
  8. self.assertTrue('nd2' in ND2Reader.class_exts())
  9. def test_init_and_init_axes(self):
  10. with ArtificialND2('test_data/test_nd2_reader.nd2') as artificial:
  11. reader = ND2Reader('test_data/test_nd2_reader.nd2')
  12. attributes = artificial.data['image_attributes']['SLxImageAttributes']
  13. self.assertEqual(reader.metadata['width'], attributes['uiWidth'])
  14. self.assertEqual(reader.metadata['height'], attributes['uiHeight'])
  15. self.assertEqual(reader.metadata['width'], reader.sizes['x'])
  16. self.assertEqual(reader.metadata['height'], reader.sizes['y'])
  17. self.assertEqual(reader._dtype, np.float64)
  18. self.assertEqual(reader.iter_axes, ['t'])
  19. def test_init_empty_file(self):
  20. with ArtificialND2('test_data/empty.nd2', skip_blocks=['label_map_marker']):
  21. with self.assertRaises(EmptyFileError) as exception:
  22. ND2Reader('test_data/empty.nd2')
  23. self.assertEqual(str(exception.exception), "No axes were found for this .nd2 file.")