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.2 KiB

  1. from nd2reader.model.image import Image
  2. import numpy as np
  3. import unittest
  4. class ImageTests(unittest.TestCase):
  5. """
  6. Basically just tests that the Image API works and that Images act as Numpy arrays. There's very little going on
  7. here other than simply storing data.
  8. """
  9. def setUp(self):
  10. array = np.array([[0, 1, 254],
  11. [45, 12, 9],
  12. [12, 12, 99]])
  13. self.image = Image(array)
  14. self.image.add_params(1, 1200.314, 17, 2, 'GFP', 1)
  15. def test_size(self):
  16. self.assertEqual(self.image.height, 3)
  17. self.assertEqual(self.image.width, 3)
  18. def test_timestamp(self):
  19. self.assertEqual(self.image.timestamp, 1.200314)
  20. def test_frame_number(self):
  21. self.assertEqual(self.image.frame_number, 17)
  22. def test_fov(self):
  23. self.assertEqual(self.image.field_of_view, 2)
  24. def test_channel(self):
  25. self.assertEqual(self.image.channel, 'GFP')
  26. def test_z_level(self):
  27. self.assertEqual(self.image.z_level, 1)
  28. def test_slice(self):
  29. subimage = self.image[:2, :2]
  30. expected = np.array([[0, 1],
  31. [45, 12]])
  32. self.assertTrue(np.array_equal(subimage, expected))