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.

68 lines
1.9 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_pixel_size(self):
  23. self.assertGreater(self.nd2.pixel_microns, 0.0)
  24. def test_actual_length(self):
  25. count = 0
  26. for image in self.nd2:
  27. if image is not None:
  28. count += 1
  29. self.assertEqual(len(self.nd2), count)
  30. def test_frames(self):
  31. self.assertEqual(len(self.nd2.frames), 1)
  32. def test_fovs(self):
  33. self.assertEqual(len(self.nd2.fields_of_view), 1)
  34. def test_z_levels(self):
  35. self.assertTupleEqual(tuple(self.nd2.z_levels), (0,))
  36. def test_image(self):
  37. image = self.nd2[0]
  38. self.assertIsNotNone(image)
  39. def test_iteration(self):
  40. images = [image for image in self.nd2]
  41. self.assertEqual(len(images), 1)
  42. def test_iteration_step(self):
  43. images = [image for image in self.nd2[::2]]
  44. self.assertEqual(len(images), 1)
  45. def test_iteration_backwards(self):
  46. images = [image for image in self.nd2[::-1]]
  47. self.assertEqual(len(images), 1)
  48. def test_select_bounds_wrong(self):
  49. images = [i for i in self.nd2.select(start=0, stop=12481247)]
  50. self.assertEqual(len(images), 1)