def test_annotation_creation(self): self.fake_authentication() neuron_ids = [2365, 2381] # Expect entity 2365 and 2381 to be not annotated for nid in neuron_ids: aq = create_annotation_query(self.test_project_id, {'neuron_id': nid}) self.assertEqual(len(aq), 0) # Annotate both with the same annotation _annotate_entities(self.test_project_id, neuron_ids, {'myannotation': {'user_id': self.test_user_id}}) # Expect entity 2365 and 2381 to be annotated for nid in neuron_ids: aq = create_annotation_query(self.test_project_id, {'neuron_id': nid}) self.assertEqual(len(aq), 1) self.assertEqual(aq[0].name, 'myannotation') # Annotate both with the pattern annotation _annotate_entities(self.test_project_id, neuron_ids, {'pattern {n9} test-{n}-annotation': { 'user_id': self.test_user_id}}) # Expect entity 2365 and 2381 to be annotated aq = create_annotation_query(self.test_project_id, {'neuron_id': 2365}).order_by('name') self.assertEqual(len(aq), 2) self.assertEqual(aq[0].name, 'myannotation') self.assertEqual(aq[1].name, 'pattern 9 test-1-annotation') aq = create_annotation_query(self.test_project_id, {'neuron_id': 2381}).order_by('name') self.assertEqual(len(aq), 2) self.assertEqual(aq[0].name, 'myannotation') self.assertEqual(aq[1].name, 'pattern 10 test-2-annotation')
def test_annotation_creation(self): self.fake_authentication() neuron_ids = [2365, 2381] # Expect entity 2365 and 2381 to be not annotated for nid in neuron_ids: aq = create_annotation_query(self.test_project_id, {'neuron_id': nid}) self.assertEqual(len(aq), 0) # Annotate both with the same annotation _annotate_entities(self.test_project_id, neuron_ids, {'myannotation': self.test_user_id}) # Expect entity 2365 and 2381 to be annotated for nid in neuron_ids: aq = create_annotation_query(self.test_project_id, {'neuron_id': nid}) self.assertEqual(len(aq), 1) self.assertEqual(aq[0].name, 'myannotation') # Annotate both with the pattern annotation _annotate_entities(self.test_project_id, neuron_ids, {'pattern {n9} test-{n}-annotation': self.test_user_id}) # Expect entity 2365 and 2381 to be annotated aq = create_annotation_query(self.test_project_id, {'neuron_id': 2365}).order_by('name') self.assertEqual(len(aq), 2) self.assertEqual(aq[0].name, 'myannotation') self.assertEqual(aq[1].name, 'pattern 9 test-1-annotation') aq = create_annotation_query(self.test_project_id, {'neuron_id': 2381}).order_by('name') self.assertEqual(len(aq), 2) self.assertEqual(aq[0].name, 'myannotation') self.assertEqual(aq[1].name, 'pattern 10 test-2-annotation')
def check_annotations_on_split(project_id, skeleton_id, over_annotation_set, under_annotation_set): """ With respect to annotations, a split is only correct if one part keeps the whole set of annotations. """ # Get current annotation set annotation_query = create_annotation_query(project_id, {'skeleton_id': skeleton_id}) # Check if current set is equal to under or over set current_annotation_set = frozenset(a.name for a in annotation_query) if not current_annotation_set.difference(over_annotation_set): return True if not current_annotation_set.difference(under_annotation_set): return True return False