From 98877016f318ebff8ae612f06e1d5191d4c4bc6d Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sat, 5 Sep 2015 20:18:55 -0500 Subject: [PATCH] Allow polygon to take a list or tuple and add a test --- skimage/draw/_draw.pyx | 2 ++ skimage/draw/tests/test_draw.py | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/skimage/draw/_draw.pyx b/skimage/draw/_draw.pyx index c2df55ff..3a0d3612 100644 --- a/skimage/draw/_draw.pyx +++ b/skimage/draw/_draw.pyx @@ -268,6 +268,8 @@ def polygon(y, x, shape=None): [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8) """ + x = np.asanyarray(x) + y = np.asanyarray(y) cdef Py_ssize_t nr_verts = x.shape[0] cdef Py_ssize_t minr = int(max(0, y.min())) diff --git a/skimage/draw/tests/test_draw.py b/skimage/draw/tests/test_draw.py index c1af1a80..a07ca631 100644 --- a/skimage/draw/tests/test_draw.py +++ b/skimage/draw/tests/test_draw.py @@ -122,9 +122,8 @@ def test_line_equal_aliasing_horizontally_vertically(): def test_polygon_rectangle(): img = np.zeros((10, 10), 'uint8') - poly = np.array(((1, 1), (4, 1), (4, 4), (1, 4), (1, 1))) - rr, cc = polygon(poly[:, 0], poly[:, 1]) + rr, cc = polygon((1, 4, 4, 1, 1), (1, 1, 4, 4, 1)) img[rr, cc] = 1 img_ = np.zeros((10, 10))