Esempio n. 1
0
 def test_update_folder_info_from(self):
     well = AnnotatedWellFolder()
     labeled_f0 = AnnotatedImage(INFO_F0, '1-cell')
     well._update_info_from(labeled_f0.info)
     is_ok = [getattr(well, a) == getattr(labeled_f0.info, a)
              for a in well._check_attrs]
     self.assertTrue(all(is_ok))
Esempio n. 2
0
    def test_getitem(self):
        well = AnnotatedWellFolder()
        labeled_f0 = AnnotatedImage(INFO_F0, '1-cell')
        well.update_with(labeled_f0)

        gotten = well[labeled_f0.info.focus]
        self.assertIs(type(gotten), AnnotatedFocusFolder)
Esempio n. 3
0
    def test_collate_wells(self):
        label = AnnotatedImage(INFO_F0, '1-cell')
        data = AnnotatedImage(label.info, [0, 1, 2])

        well_labeled = AnnotatedWellFolder.create_from(label)
        well_data = AnnotatedWellFolder.create_from(data)

        collated = well_labeled.collate_annotations_with(well_data)
        well_labeled.update_with(data)
        self.assertEqual(well_labeled, collated)
Esempio n. 4
0
    def test_update_with_when_empty(self):
        well = AnnotatedWellFolder()
        labeled_f0 = AnnotatedImage(INFO_F0, '1-cell')
        well.update_with(labeled_f0)

        self.assertEqual(len(well), 1)

        info_ok = [getattr(well, a) == getattr(labeled_f0.info, a)
                   for a in well._check_attrs]
        self.assertTrue(all(info_ok))
        type_ok = type(well[labeled_f0.info.focus]) == AnnotatedFocusFolder
        self.assertTrue(type_ok)
Esempio n. 5
0
    def test_remove_recursively_when_image_is_not_in_wellfolder(self):
        labeled1 = AnnotatedImage(INFO_F0, '1-cell')
        labeled2 = AnnotatedImage(INFO_F0_2, '1-cell')
        well = AnnotatedWellFolder.create_from(labeled1)
        well.update_with(labeled2)

        labeled_notin = AnnotatedImage(INFO_FP, '1-cell')
        self.assertRaises(ValueError, well.remove, labeled_notin)
Esempio n. 6
0
 def test_add_entry_from_includes_in_dict(self):
     well = AnnotatedWellFolder()
     image1 = AnnotatedImage(INFO_F0, '1-cell')
     well.update_with(image1)
     image2 = AnnotatedImage(INFO_F0_2, '1-cell')
     well._add_entry_from(image2)
     self.assertTrue(well.contains_image(image2.info))
Esempio n. 7
0
    def test_iterate_over_images(self):
        labeled1 = AnnotatedImage(INFO_F0, '1-cell')
        labeled2 = AnnotatedImage(INFO_F0_2, '1-cell')
        well = AnnotatedWellFolder.create_from(labeled1)
        well.update_with(labeled2)

        images = [i for i in well.iterate_over_images()]
        self.assertEqual(len(images), 2)
        self.assertIn(labeled1, images)
        self.assertIn(labeled2, images)
Esempio n. 8
0
    def test_remove_recursively_when_image_is_in_wellfolder(self):
        labeled1 = AnnotatedImage(INFO_F0, '1-cell')
        labeled2 = AnnotatedImage(INFO_F0_2, '1-cell')
        well = AnnotatedWellFolder.create_from(labeled1)
        well.update_with(labeled2)

        well.remove(labeled1, recursive=True)
        # There should still be 1 focus:
        self.assertEqual(len(well), 1)
        # But the image should not be in the focus folder:
        focus = [i for i in well][0]
        self.assertTrue(labeled1 not in focus)
Esempio n. 9
0
 def test_does_update_with_if_same_well(self):
     well = AnnotatedWellFolder()
     labeled_f0 = AnnotatedImage(INFO_F0, '1-cell')
     well.update_with(labeled_f0)
     labeled_fm_2 = AnnotatedImage(INFO_FM_2, '1-cell')
     well.update_with(labeled_fm_2)
     self.assertEqual(len(well), 2)
Esempio n. 10
0
 def test_does_update_with_if_same_focus(self):
     well = AnnotatedWellFolder()
     labeled_f0 = AnnotatedImage(INFO_F0, '1-cell')
     well.update_with(labeled_f0)
     labeled_f0_2 = AnnotatedImage(INFO_F0_2, '1-cell')
     well.update_with(labeled_f0_2)
     # Then the length should be 1, since it should update the same
     # dictionary!
     self.assertEqual(len(well), 1)
Esempio n. 11
0
 def test_deprettify(self):
     focus_value = 15
     pretty = AnnotatedWellFolder._prettify(focus_value)
     back = AnnotatedWellFolder._de_prettify(pretty)
     self.assertEqual(back, focus_value)
Esempio n. 12
0
 def test_prettify(self):
     focus_value = 15
     correct = 'F15'
     output = AnnotatedWellFolder._prettify(focus_value)
     self.assertEqual(output, correct)
Esempio n. 13
0
 def test_does_not_update_with_if_different_well(self):
     well = AnnotatedWellFolder()
     labeled_f0 = AnnotatedImage(INFO_F0, '1-cell')
     well.update_with(labeled_f0)
     labeled_fp = AnnotatedImage(INFO_FP, '1-cell')
     self.assertRaises(ValueError, well.update_with, labeled_fp)
Esempio n. 14
0
 def test_len_is_zero_on_init(self):
     well = AnnotatedWellFolder()
     self.assertEqual(len(well), 0)
Esempio n. 15
0
 def test_init_does_not_crash(self):
     well = AnnotatedWellFolder()
     self.assertTrue(well is not None)