From 2f29459ade04e399e55fa9f4334265de60a9b4cd Mon Sep 17 00:00:00 2001 From: Adam Scibior Date: Mon, 15 May 2017 17:17:59 +0100 Subject: [PATCH] Fix weave imports --- spearmint/kernels/kernel_utils.py | 9 ++++++--- spearmint/models/gp_classifier.py | 5 ++++- spearmint/utils/linalg.py | 9 ++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/spearmint/kernels/kernel_utils.py b/spearmint/kernels/kernel_utils.py index c84248d..c90bbcb 100755 --- a/spearmint/kernels/kernel_utils.py +++ b/spearmint/kernels/kernel_utils.py @@ -184,7 +184,10 @@ import numpy as np -import scipy.weave +try: + import scipy.weave as weave +except ImportError: + import weave from scipy.spatial.distance import cdist def dist2(ls, x1, x2=None): @@ -228,8 +231,8 @@ def grad_dist2(ls, x1, x2=None): gX(i,j,d) = (2/ls(d))*(x1(i,d) - x2(j,d)); """ try: - scipy.weave.inline(code, ['x1','x2','gX','ls','M','N','D'], \ - type_converters=scipy.weave.converters.blitz, \ + weave.inline(code, ['x1','x2','gX','ls','M','N','D'], \ + type_converters=weave.converters.blitz, \ compiler='gcc') except: # The C code weave above is 10x faster than this: diff --git a/spearmint/models/gp_classifier.py b/spearmint/models/gp_classifier.py index 32ce8ad..d3df302 100755 --- a/spearmint/models/gp_classifier.py +++ b/spearmint/models/gp_classifier.py @@ -191,7 +191,10 @@ import scipy.optimize as spo import scipy.io as sio import scipy.stats as sps -import scipy.weave +try: + import scipy.weave as weave +except ImportError: + import weave from .gp import GP diff --git a/spearmint/utils/linalg.py b/spearmint/utils/linalg.py index 659f02a..69540d8 100755 --- a/spearmint/utils/linalg.py +++ b/spearmint/utils/linalg.py @@ -184,7 +184,10 @@ import numpy as np -import scipy.weave +try: + import scipy.weave as weave +except ImportError: + import weave import scipy.linalg as spla # Update Cholesky decomposition to include a single extra @@ -237,8 +240,8 @@ def fast_chol_add(L, A): } } """ - scipy.weave.inline(code, ['U','A','j','isPosDef','rows','cols'], \ - type_converters=scipy.weave.converters.blitz, \ + weave.inline(code, ['U','A','j','isPosDef','rows','cols'], \ + type_converters=weave.converters.blitz, \ compiler='gcc') except: k = np.arange(cols)