From 3ea78096e7ef5bae3e97a89a132acb73e0a39f9c Mon Sep 17 00:00:00 2001 From: Vighnesh Birodkar Date: Mon, 16 Jun 2014 23:02:01 +0530 Subject: [PATCH] Formatting changes --- skimage/graph/graph_cut.py | 5 ++--- skimage/graph/tests/test_rag.py | 34 +++++++++++++++------------------ 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/skimage/graph/graph_cut.py b/skimage/graph/graph_cut.py index 2733bf0e..7c183689 100644 --- a/skimage/graph/graph_cut.py +++ b/skimage/graph/graph_cut.py @@ -31,10 +31,9 @@ def threshold_cut(label, rag, thresh): >>> labels = segmentation.slic(img) >>> rag = graph.rag_meancolor(img, labels) >>> new_labels = graph.threshold_cut(labels, rag, 10) - """ - to_remove = [(x, y) - for x, y, d in rag.edges_iter(data=True) if d['weight'] >= thresh] + to_remove = [(x, y) for x, y, d in rag.edges_iter(data=True) + if d['weight'] >= thresh] rag.remove_edges_from(to_remove) diff --git a/skimage/graph/tests/test_rag.py b/skimage/graph/tests/test_rag.py index d24c62c4..fdf3fee7 100644 --- a/skimage/graph/tests/test_rag.py +++ b/skimage/graph/tests/test_rag.py @@ -1,29 +1,25 @@ import numpy as np from skimage import graph + def test_threshold_cut(): - - img = np.zeros((100,100,3),dtype='uint8') - img[:50,:50] = 255,255,255 - img[:50,50:] = 254,254,254 - img[50:,:50] = 2,2,2 - img[50:,50:] = 1,1,1 + img = np.zeros((100, 100, 3), dtype='uint8') + img[:50, :50] = 255, 255, 255 + img[:50, 50:] = 254, 254, 254 + img[50:, :50] = 2, 2, 2 + img[50:, 50:] = 1, 1, 1 + labels = np.zeros((100, 100), dtype='uint8') + labels[:50, :50] = 0 + labels[:50, 50:] = 1 + labels[50:, :50] = 2 + labels[50:, 50:] = 3 - labels = np.zeros((100,100),dtype='uint8') - labels[:50,:50] = 0 - labels[:50,50:] = 1 - labels[50:,:50] = 2 - labels[50:,50:] = 3 - - - #print labels + # print labels rag = graph.rag_meancolor(img, labels) - #print "no of edges",rag.number_of_edges() + # print "no of edges",rag.number_of_edges() new_labels = graph.threshold_cut(labels, rag, 10) - - assert new_labels.max() == 2 - #assert False - + assert new_labels.max() == 2 + # assert False