From 33469fa69eb53143ae09bd710ea46f8f05f42090 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Fri, 28 Oct 2011 14:56:41 -0700 Subject: [PATCH] BUG: Allow test suite to pass with scipy < 0.9. --- skimage/morphology/convex_hull.py | 7 ++++++- skimage/morphology/tests/test_convex_hull.py | 10 +++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/skimage/morphology/convex_hull.py b/skimage/morphology/convex_hull.py index 034acd0b..487a547b 100644 --- a/skimage/morphology/convex_hull.py +++ b/skimage/morphology/convex_hull.py @@ -1,7 +1,6 @@ __all__ = ['convex_hull'] import numpy as np -from scipy.spatial import Delaunay from ._pnpoly import points_inside_poly, grid_points_inside_poly from ._convex_hull import possible_hull @@ -44,6 +43,12 @@ def convex_hull(image): coords = coords_corners + try: + from scipy.spatial import Delaunay + except ImportError: + raise ImportError('Could not import scipy.spatial, only available in ' + 'scipy >= 0.9.') + # Find the convex hull chull = Delaunay(coords).convex_hull v = coords[np.unique(chull)] diff --git a/skimage/morphology/tests/test_convex_hull.py b/skimage/morphology/tests/test_convex_hull.py index 2d150abd..e8fb5514 100644 --- a/skimage/morphology/tests/test_convex_hull.py +++ b/skimage/morphology/tests/test_convex_hull.py @@ -1,8 +1,16 @@ import numpy as np from numpy.testing import assert_array_equal +from numpy.testing.decorators import skipif from skimage.morphology import convex_hull from skimage.morphology._convex_hull import possible_hull +try: + import scipy.spatial + scipy_spatial = True +except ImportError: + scipy_spatial = False + +@skipif(not scipy_spatial) def test_basic(): image = np.array( [[0, 0, 0, 0, 0, 0, 0, 0, 0], @@ -22,7 +30,7 @@ def test_basic(): assert_array_equal(convex_hull(image), expected) - +@skipif(not scipy_spatial) def test_possible_hull(): image = np.array( [[0, 0, 0, 0, 0, 0, 0, 0, 0],