From c14021a9cbd16f07526adf08a7aff508521b6f0a Mon Sep 17 00:00:00 2001 From: Vighnesh Birodkar Date: Mon, 23 Jun 2014 01:16:57 +0530 Subject: [PATCH] Formatting and typos --- skimage/graph/graph_cut.py | 2 +- skimage/graph/tests/test_rag.py | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/skimage/graph/graph_cut.py b/skimage/graph/graph_cut.py index 27e4400d..1105d423 100644 --- a/skimage/graph/graph_cut.py +++ b/skimage/graph/graph_cut.py @@ -46,7 +46,7 @@ def threshold_cut(label_image, rag, thresh): comps = nx.connected_components(rag) - map_array = np.arange(label_image.max()+1, dtype = np.int) + map_array = np.arange(label_image.max()+1, dtype=np.int) for i, nodes in enumerate(comps): for node in nodes: for label in rag.node[node]['labels']: diff --git a/skimage/graph/tests/test_rag.py b/skimage/graph/tests/test_rag.py index 015999f5..bdaf8277 100644 --- a/skimage/graph/tests/test_rag.py +++ b/skimage/graph/tests/test_rag.py @@ -2,10 +2,12 @@ import numpy as np from skimage import graph import random -def _min_edge(e1,e2,g): + +def _min_edge(e1, e2, g): w1 = g.edge[e1[0]][e1[1]]['weight'] w2 = g.edge[e2[0]][e2[1]]['weight'] - return min(w1,w2) + return min(w1, w2) + def test_rag_merge(): g = graph.rag.RAG() @@ -16,16 +18,16 @@ def test_rag_merge(): for i in range(4): x = random.choice(g.nodes()) y = random.choice(g.nodes()) - while x == y : + while x == y: y = random.choice(g.nodes()) - g.merge_nodes(x,y) - + g.merge_nodes(x, y) + for i in range(5): x = random.choice(g.nodes()) y = random.choice(g.nodes()) - while x == y : + while x == y: y = random.choice(g.nodes()) - g.merge_nodes(x,y,_min_edge) + g.merge_nodes(x, y, _min_edge) idx = g.nodes()[0] assert sorted(g.node[idx]['labels']) == list(range(10))