mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-05 01:32:40 +02:00
Merge branch 'cython-fix' of git://github.com/jayanthkoushik/GPy into jayanthkoushik-cython-fix
This commit is contained in:
commit
da82f356a8
6 changed files with 55 additions and 37 deletions
|
|
@ -4,11 +4,14 @@
|
|||
import numpy as np
|
||||
from . import linalg
|
||||
from .config import config
|
||||
|
||||
try:
|
||||
from . import choleskies_cython
|
||||
config.set('cython', 'working', 'True')
|
||||
use_choleskies_cython = config.getboolean('cython', 'working')
|
||||
except ImportError:
|
||||
config.set('cython', 'working', 'False')
|
||||
print('warning in choleskies: failed to import cython module: falling back to numpy')
|
||||
use_choleskies_cython = False
|
||||
|
||||
|
||||
def safe_root(N):
|
||||
i = np.sqrt(N)
|
||||
|
|
@ -100,7 +103,7 @@ def indexes_to_fix_for_low_rank(rank, size):
|
|||
return np.setdiff1d(np.arange((size**2+size)/2), keep)
|
||||
|
||||
|
||||
if config.getboolean('cython', 'working'):
|
||||
if use_choleskies_cython:
|
||||
triang_to_flat = _triang_to_flat_cython
|
||||
flat_to_triang = _flat_to_triang_cython
|
||||
backprop_gradient = choleskies_cython.backprop_gradient_par_c
|
||||
|
|
|
|||
|
|
@ -11,8 +11,11 @@ from scipy.linalg import lapack, blas
|
|||
from .config import config
|
||||
import logging
|
||||
|
||||
if config.getboolean('cython', 'working'):
|
||||
try:
|
||||
from . import linalg_cython
|
||||
use_linalg_cython = config.getboolean('cython', 'working')
|
||||
except ImportError:
|
||||
use_linalg_cython = False
|
||||
|
||||
def force_F_ordered_symmetric(A):
|
||||
"""
|
||||
|
|
@ -359,7 +362,7 @@ def symmetrify(A, upper=False):
|
|||
|
||||
note: tries to use cython, falls back to a slower numpy version
|
||||
"""
|
||||
if config.getboolean('cython', 'working'):
|
||||
if use_linalg_cython:
|
||||
_symmetrify_cython(A, upper)
|
||||
else:
|
||||
_symmetrify_numpy(A, upper)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue