diff --git a/functional_tests/monocycle.py b/functional_tests/monocycle.py index 08eca5d..0c1b79d 100644 --- a/functional_tests/monocycle.py +++ b/functional_tests/monocycle.py @@ -14,9 +14,10 @@ class Monocycle1Tests(unittest.TestCase): def tearDown(self): self.nd2.close() + def test_channels(self): + self.assertListEqual(self.nd2.channels, ['Cy3Narrow', 'TxRed-modified', 'FITC', 'DAPI']) + def test_select(self): - # If we take the first 20 GFP images, they should be identical to the first 20 items iterated from select() - # if we set our criteria to just "GFP" manual_images = [] for _, image in zip(range(20), self.nd2): if image is not None and image.channel == 'FITC': @@ -39,7 +40,9 @@ class Monocycle1Tests(unittest.TestCase): def test_select_order_all(self): # If we select every possible image using select(), we should just get every image in order n = 0 - for image in self.nd2.select(channels=['Cy3Narrow', 'DAPI', 'FITC', 'TxRed-modified'], z_levels=list(range(35)), fields_of_view=list(range(5))): + for image in self.nd2.select(channels=['Cy3Narrow', 'DAPI', 'FITC', 'TxRed-modified'], + z_levels=list(range(35)), + fields_of_view=list(range(5))): while True: indexed_image = self.nd2[n] if indexed_image is not None: @@ -48,14 +51,17 @@ class Monocycle1Tests(unittest.TestCase): self.assertTrue(np.array_equal(image, indexed_image)) n += 1 if n > 100: - # Quit after the first hundred images just to save time. If there's a problem, we'll have seen it by now. + # Quit after the first hundred images just to save time. + # If there's a problem, we'll have seen it by now. break def test_select_order_subset(self): # Test that images are always yielded in increasing order. This guarantees that no matter what subset of images # we're filtering, we still get them in the chronological order they were acquired n = -1 - for image in self.nd2.select(channels='FITC', z_levels=[0, 1], fields_of_view=[1, 2, 4]): + for image in self.nd2.select(channels='FITC', + z_levels=[0, 1], + fields_of_view=[1, 2, 4]): self.assertGreater(image.index, n) self.assertEqual(image.channel, 'FITC') self.assertIn(image.field_of_view, (1, 2, 4)) @@ -73,8 +79,6 @@ class Monocycle2Tests(unittest.TestCase): self.nd2.close() def test_select(self): - # If we take the first 20 HHQ 500 LP 1 images, they should be identical to the first 20 items iterated from select() - # if we set our criteria to just "HHQ 500 LP 1" manual_images = [] for _, image in zip(range(20), self.nd2): if image is not None and image.channel == 'HHQ 500 LP 1': @@ -97,7 +101,9 @@ class Monocycle2Tests(unittest.TestCase): def test_select_order_all(self): # If we select every possible image using select(), we should just get every image in order n = 0 - for image in self.nd2.select(channels=['HHQ 500 LP 1', 'HHQ 500 LP 2'], z_levels=[0], fields_of_view=list(range(100))): + for image in self.nd2.select(channels=['HHQ 500 LP 1', 'HHQ 500 LP 2'], + z_levels=[0], + fields_of_view=list(range(100))): while True: indexed_image = self.nd2[n] if indexed_image is not None: @@ -106,14 +112,17 @@ class Monocycle2Tests(unittest.TestCase): self.assertTrue(np.array_equal(image, indexed_image)) n += 1 if n > 100: - # Quit after the first hundred images just to save time. If there's a problem, we'll have seen it by now. + # Quit after the first hundred images just to save time. + # If there's a problem, we'll have seen it by now. break def test_select_order_subset(self): # Test that images are always yielded in increasing order. This guarantees that no matter what subset of images # we're filtering, we still get them in the chronological order they were acquired n = -1 - for image in self.nd2.select(channels='HHQ 500 LP 2', z_levels=[0], fields_of_view=[1, 2, 4]): + for image in self.nd2.select(channels='HHQ 500 LP 2', + z_levels=[0], + fields_of_view=[1, 2, 4]): self.assertGreater(image.index, n) self.assertEqual(image.channel, 'HHQ 500 LP 2') self.assertIn(image.field_of_view, (1, 2, 4)) diff --git a/functional_tests/single.py b/functional_tests/single.py index d9c8b54..5d68b57 100644 --- a/functional_tests/single.py +++ b/functional_tests/single.py @@ -25,6 +25,9 @@ class SingleTests(unittest.TestCase): def test_length(self): self.assertEqual(len(self.nd2), 1) + def test_channels(self): + self.assertEqual(self.nd2.channels, ['Quad Band 2']) + def test_actual_length(self): count = 0 for image in self.nd2: