From a410f1c47e87077d9670cfcf2bc36f4f1807bf5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 9 Dec 2012 23:17:06 +0100 Subject: [PATCH] UmfPack warning is now only raised if random walker is explicitly called --- .../segmentation/random_walker_segmentation.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/skimage/segmentation/random_walker_segmentation.py b/skimage/segmentation/random_walker_segmentation.py index 6eb7def8..397c4299 100644 --- a/skimage/segmentation/random_walker_segmentation.py +++ b/skimage/segmentation/random_walker_segmentation.py @@ -14,13 +14,9 @@ import numpy as np from scipy import sparse, ndimage try: from scipy.sparse.linalg.dsolve import umfpack - u = umfpack.UmfpackContext() + UmfpackContext = umfpack.UmfpackContext() except: - warnings.warn("""Scipy was built without UMFPACK. Consider rebuilding - Scipy with UMFPACK, this will greatly speed up the random walker - functions. You may also install pyamg and run the random walker function - in cg_mg mode (see the docstrings) - """) + UmfpackContext = None try: from pyamg import ruge_stuben_solver amg_loaded = True @@ -338,6 +334,14 @@ def random_walker(data, labels, beta=130, mode='bf', tol=1.e-3, copy=True, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]], dtype=int32) """ + + if UmfpackContext is None: + warnings.warn('SciPy was built without UMFPACK. Consider rebuilding ' + 'SciPy with UMFPACK, this will greatly speed up the ' + 'random walker functions. You may also install pyamg ' + 'and run the random walker function in cg_mg mode ' + '(see the docstrings)') + # Parse input data if not multichannel: # We work with 4-D arrays of floats