示例#1
0
 def test_extract_edges(self):
     grid = cv2.imread(fixtures_path('grid.png'), 0)
     matches = [
         ((0, 0), (3, 3)),
         ((1, 11), (4, 14)),
         ((8, 12), (11, 15)),
     ]
     with open(fixtures_path('graph.json'), 'r') as json_graph:
         graph = json.load(json_graph)
     edges = histonets.extract_edges(grid, matches)
     json_edges = json.loads(utils.serialize_json(edges))
     assert (all(edge in json_edges for edge in graph)
             and all(edge in graph for edge in json_edges))
示例#2
0
 def test_command_graph_gexf_tolerance(self):
     matches = [
         ((0, 0), (3, 3)),
         ((1, 11), (4, 14)),
         ((8, 12), (11, 15)),
     ]
     regions = utils.serialize_json(matches)
     result = self.runner.invoke(
         cli.graph,
         [regions, '-f', 'gexf', '-st', 0, self.image_grid]
     )
     out = nx.read_gexf(io.StringIO(result.output.strip()))
     graph = nx.read_gexf(fixtures_path('graph.gexf'))
     assert nodeset(out) == nodeset(graph)
     assert edgeset(out) == edgeset(graph)
示例#3
0
 def test_command_graph(self):
     matches = [
         ((0, 0), (3, 3)),
         ((1, 11), (4, 14)),
         ((8, 12), (11, 15)),
     ]
     regions = utils.serialize_json(matches)
     result = self.runner.invoke(
         cli.graph,
         [regions, self.image_grid]
     )
     out = nx.parse_graphml(result.output.strip())
     graph = nx.read_gml(fixtures_path('graph.gml'))
     assert nodeset(out) == nodeset(graph)
     assert edgeset(out) == edgeset(graph)