From 2a339fe69cbca2a871b5b2425caee417d462a928 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 4 Aug 2014 07:40:37 -0500 Subject: [PATCH] Improve import behavior for rag fallback --- skimage/graph/rag.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/skimage/graph/rag.py b/skimage/graph/rag.py index fc4a1aaa..7c1b7f07 100644 --- a/skimage/graph/rag.py +++ b/skimage/graph/rag.py @@ -1,11 +1,13 @@ try: import networkx as nx except ImportError: + msg = "Graph functions require networkx, which is not installed" class nx: class Graph: - pass + def __init__(self, *args, **kwargs): + raise ImportError(msg) import warnings - warnings.warn('Region Adjacency Graph (RAG) features require networkx') + warnings.warn(msg) import numpy as np from scipy.ndimage import filters from scipy import ndimage as nd