From f267f656664ea4040cfe78de7c2da90487ef10c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 15 Aug 2012 09:04:06 +0200 Subject: [PATCH] add test case for subdivision of polygons --- skimage/measure/tests/test_polygon.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/skimage/measure/tests/test_polygon.py b/skimage/measure/tests/test_polygon.py index e539f69c..4644fa84 100644 --- a/skimage/measure/tests/test_polygon.py +++ b/skimage/measure/tests/test_polygon.py @@ -1,15 +1,16 @@ import numpy as np -from skimage.measure import approximate_polygon +from skimage.measure import approximate_polygon, subdivide_polygon + + +square = np.array([ + [0, 0], [0, 1], [0, 2], [0, 3], + [1, 3], [2, 3], [3, 3], + [3, 2], [3, 1], [3, 0], + [2, 0], [1, 0], [0, 0] +]) def test_approximate_polygon(): - square = np.array([ - [0, 0], [0, 1], [0, 2], [0, 3], - [1, 3], [2, 3], [3, 3], - [3, 2], [3, 1], [3, 0], - [2, 0], [1, 0], [0, 0] - ]) - out = approximate_polygon(square, 0.1) np.testing.assert_array_equal(out, square[(0, 3, 6, 9, 12), :]) @@ -23,5 +24,12 @@ def test_approximate_polygon(): np.testing.assert_array_equal(out, square) +def test_subdivide_polygon(): + for degree in range(1, 7): + out = subdivide_polygon(square, degree) + np.testing.assert_array_equal(out[-1], out[0]) + np.testing.assert_equal(out.shape[0], 2 * square.shape[0] - 1) + + if __name__ == "__main__": np.testing.run_module_suite()