From 7e7f0914e950387b7bcb4d94c843115080acccd8 Mon Sep 17 00:00:00 2001 From: pbrod Date: Sun, 29 Nov 2015 17:32:07 +0100 Subject: [PATCH] Add try except when importing the compiled extensions --- wafo/gaussian.py | 22 ++++++++++++++++++---- wafo/misc.py | 5 ++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/wafo/gaussian.py b/wafo/gaussian.py index 2602cfc..d33dec1 100644 --- a/wafo/gaussian.py +++ b/wafo/gaussian.py @@ -4,13 +4,27 @@ from numpy import (r_, minimum, maximum, atleast_1d, atleast_2d, mod, ones, from numpy import triu from scipy.special import ndtr as cdfnorm, ndtri as invnorm from scipy.special import erfc -from wafo import mvn -import numpy as np -import wafo.mvnprdmod as mvnprdmod -import wafo.rindmod as rindmod import warnings +import numpy as np from wafo.misc import common_shape +try: + import mvn # @UnresolvedImport +except ImportError: + warnings.warn('mvn not found. Check its compilation.') + mvn = None +try: + import mvnprodmod # @UnresolvedImport +except ImportError: + warnings.warn('mvnprodmod not found. Check its compilation.') + mvnprodmod = None +try: + import rindmod # @UnresolvedImport +except ImportError: + warnings.warn('rindmod not found. Check its compilation.') + rindmod = None + + __all__ = ['Rind', 'rindmod', 'mvnprdmod', 'mvn', 'cdflomax', 'prbnormtndpc', 'prbnormndpc', 'prbnormnd', 'cdfnorm2d', 'prbnorm2d', 'cdfnorm', 'invnorm', 'test_docstring'] diff --git a/wafo/misc.py b/wafo/misc.py index c6f1be3..6c8c7d5 100644 --- a/wafo/misc.py +++ b/wafo/misc.py @@ -18,11 +18,10 @@ import warnings from time import strftime, gmtime from plotbackend import plotbackend from collections import OrderedDict - - try: import c_library as clib # @UnresolvedImport -except: +except ImportError: + warnings.warn('c_library not found. Check its compilation.') clib = None floatinfo = finfo(float) _TINY = np.finfo(float).tiny