Ejemplo n.º 1
0
 def test_fix_up_edges_excluded_edges(self):
     self.assertEqual(syntax_only_excluded_edge_types, all_edge_types.difference(syntax_only_edge_types))
     for graph, instances in tqdm(self.task.graphs_and_instances):
         graph, _ = Model.fix_up_edges(graph, instances, excluded_edge_types=syntax_only_excluded_edge_types)
         for e in graph.edges:
             if e[3]['type'].startswith('reverse_'):
                 e[3]['type'] = e[3]['type'][8:]
             self.assertIn(e[3]['type'], syntax_only_edge_types)
Ejemplo n.º 2
0
 def test_fix_up_edges(self):
     for graph, instances in tqdm(self.task.graphs_and_instances):
         for e in graph.edges:
             self.assertIn(e[3]['type'], all_edge_types, "Found a weird edge type in the data")
         orig_graph = deepcopy(graph)
         orig_instances = deepcopy(instances)
         graph, instances = Model.fix_up_edges(graph, instances, excluded_edge_types=frozenset())
         self.assertEqual(orig_instances, instances, "Instances changes when it shouldn't have")
         correct_edges = [(e[0], e[1], e[3]) for e in orig_graph.edges]
         for e in orig_graph.edges:
             new_attrs = deepcopy(e[3])
             new_attrs['type'] = 'reverse_' + e[3]['type']
             correct_edges.append((e[1], e[0], new_attrs))
         edges_no_keys = [(e[0], e[1], e[3]) for e in graph.edges]
         self.assertCountEqual(correct_edges, edges_no_keys)