mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-04-28 22:36:24 +02:00
array handling in plotting and weave
This commit is contained in:
parent
e1bb3e508e
commit
a3bf662fd3
11 changed files with 225 additions and 202 deletions
|
|
@ -4,6 +4,18 @@
|
|||
import numpy as np
|
||||
from scipy import weave
|
||||
|
||||
### make a parameter to its corresponding array:
|
||||
def param_to_array(*param):
|
||||
"""
|
||||
Convert an arbitrary number of parameters to :class:ndarray class objects. This is for
|
||||
converting parameter objects to numpy arrays, when using scipy.weave.inline routine.
|
||||
In scipy.weave.blitz there is no automatic array detection (even when the array inherits
|
||||
from :class:ndarray)"""
|
||||
assert len(param) > 0, "At least one parameter needed"
|
||||
if len(param) == 1:
|
||||
return param[0].view(np.ndarray)
|
||||
return map(lambda x: x.view(np.ndarray), param)
|
||||
|
||||
def opt_wrapper(m, **kwargs):
|
||||
"""
|
||||
This function just wraps the optimization procedure of a GPy
|
||||
|
|
@ -106,6 +118,7 @@ def fast_array_equal(A, B):
|
|||
elif ((A == None) and (B != None)) or ((A != None) and (B == None)):
|
||||
return False
|
||||
elif A.shape == B.shape:
|
||||
A, B = param_to_array(A, B)
|
||||
if A.ndim == 2:
|
||||
N, D = [int(i) for i in A.shape]
|
||||
value = weave.inline(code2, support_code=support_code,
|
||||
|
|
@ -123,7 +136,6 @@ def fast_array_equal(A, B):
|
|||
|
||||
return value
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import pylab as plt
|
||||
X = np.linspace(1,10, 100)[:, None]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue