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.

61 lines
1.7 KiB

9 years ago
  1. """
  2. These tests require that you have a specific ND2 file created by the developer of nd2reader. You will never need to
  3. run them unless you're Jim Rybarski.
  4. """
  5. from nd2reader import Nd2
  6. from datetime import datetime
  7. import unittest
  8. class SingleTests(unittest.TestCase):
  9. def setUp(self):
  10. self.nd2 = Nd2("/var/nd2s/single.nd2")
  11. def tearDown(self):
  12. self.nd2.close()
  13. def test_shape(self):
  14. self.assertEqual(self.nd2.height, 512)
  15. self.assertEqual(self.nd2.width, 512)
  16. def test_date(self):
  17. self.assertEqual(self.nd2.date, datetime(2015, 10, 15, 9, 33, 5))
  18. def test_length(self):
  19. self.assertEqual(len(self.nd2), 1)
  20. def test_channels(self):
  21. self.assertEqual(self.nd2.channels, ['Quad Band 2'])
  22. def test_actual_length(self):
  23. count = 0
  24. for image in self.nd2:
  25. if image is not None:
  26. count += 1
  27. self.assertEqual(len(self.nd2), count)
  28. def test_frames(self):
  29. self.assertEqual(len(self.nd2.frames), 1)
  30. def test_fovs(self):
  31. self.assertEqual(len(self.nd2.fields_of_view), 1)
  32. def test_z_levels(self):
  33. self.assertTupleEqual(tuple(self.nd2.z_levels), (0,))
  34. def test_image(self):
  35. image = self.nd2[0]
  36. self.assertIsNotNone(image)
  37. def test_iteration(self):
  38. images = [image for image in self.nd2]
  39. self.assertEqual(len(images), 1)
  40. def test_iteration_step(self):
  41. images = [image for image in self.nd2[::2]]
  42. self.assertEqual(len(images), 1)
  43. def test_iteration_backwards(self):
  44. images = [image for image in self.nd2[::-1]]
  45. self.assertEqual(len(images), 1)