Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix weave imports #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions spearmint/kernels/kernel_utils.py
Original file line number Diff line number Diff line change
@@ -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:
5 changes: 4 additions & 1 deletion spearmint/models/gp_classifier.py
Original file line number Diff line number Diff line change
@@ -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
9 changes: 6 additions & 3 deletions spearmint/utils/linalg.py
Original file line number Diff line number Diff line change
@@ -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)