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.

42 lines
1.3 KiB

  1. import unittest
  2. from nd2reader.reader import ND2Reader
  3. class TestReader(unittest.TestCase):
  4. def setUp(self):
  5. self.files = [
  6. './test_data/data001.nd2',
  7. './test_data/data002.nd2'
  8. ]
  9. def test_sizes_data_001(self):
  10. with ND2Reader(self.files[0]) as reader:
  11. self.assertEqual(reader.sizes['x'], 128)
  12. self.assertEqual(reader.sizes['y'], 128)
  13. self.assertEqual(reader.sizes['t'], 982)
  14. self.assertEqual(reader.sizes['c'], 1)
  15. self.assertEqual(reader.sizes['z'], 1)
  16. def test_frame_size_data_001(self):
  17. with ND2Reader(self.files[0]) as reader:
  18. frame = reader[13]
  19. self.assertEqual(frame.shape[0], 128)
  20. self.assertEqual(frame.shape[1], 128)
  21. def test_sizes_data_002(self):
  22. with ND2Reader(self.files[1]) as reader:
  23. self.assertEqual(reader.sizes['x'], 512)
  24. self.assertEqual(reader.sizes['y'], 256)
  25. self.assertEqual(reader.sizes['t'], 78)
  26. self.assertEqual(reader.sizes['c'], 1)
  27. self.assertEqual(reader.sizes['z'], 1)
  28. def test_frame_size_data_002(self):
  29. with ND2Reader(self.files[1]) as reader:
  30. frame = reader[13]
  31. self.assertEqual(frame.shape[1], 512)
  32. self.assertEqual(frame.shape[0], 256)