# Path: pygp/covar/se.py
# class SqexpCFARD(CovarianceFunction):
#     def __init__(self,*args,**kwargs):
#     def get_hyperparameter_names(self):
#     def get_number_of_parameters(self):
#     def K(self, theta, x1, x2=None):
#     def Kdiag(self,theta, x1):
#     def Kgrad_theta(self, theta, x1, i):
#     def Kgrad_x(self,theta,x1,x2,d):
#     def Kgrad_xdiag(self,theta,x1,d):
#         V0 = SP.exp(2*theta[0])
#         L  = SP.exp(theta[1:1+self.n_dimensions])
#         V0 = SP.exp(2*theta[0])
#         V0 = SP.exp(2*theta[0])
#         L  = SP.exp(theta[1:1+self.n_dimensions])
#         L2 = SP.exp(2*theta[1:1+self.n_dimensions])
#         RV = SP.zeros([x1.shape[0]])
# 
# Path: pygp/covar/combinators.py
# class SumCF(CovarianceFunction):
# class ProductCF(CovarianceFunction):
# class ShiftCF(CovarianceFunction):
#     def __init__(self, covars, *args, **kw_args):
#     def get_hyperparameter_names(self):
#     def K(self, theta, x1, x2=None):
#     def Kgrad_theta(self, theta, x1, i):
#     def Kgrad_x(self, theta, x1, x2, d):
#     def Kgrad_xdiag(self, theta, x1, d):
#     def __init__(self, covars, *args, **kw_args):
#     def get_hyperparameter_names(self):
#     def K(self, theta, x1, x2=None):
#     def Kgrad_theta(self, theta, x, i):
#     def Kgrad_x(self, theta, x1, x2, d):
#     def Kgrad_xdiag(self, theta, x1, d):
#     def __init__(self, covar, replicate_indices, *args, **kw_args):
#     def get_hyperparameter_names(self):
#     def K(self, theta, x1, x2=None):
#     def Kgrad_theta(self, theta, x, i):
#     def _shift_x(self, x, T):
#             K_ = covar.K(_theta, x1, x2)
#                 K = K_
#         RV = sp.zeros([x1.shape[0], x1.shape[0]])
#         RV = sp.zeros([x1.shape[0]])
#             K = sp.ones([x1.shape[0], x1.shape[0]])
#             K = sp.ones([x1.shape[0], x2.shape[0]])
#         T = theta[covar_n_hyper:covar_n_hyper + self.n_replicates]
#         K = self.covar.K(theta[:covar_n_hyper], shift_x1, x2)
#         T = theta[covar_n_hyper:covar_n_hyper + self.n_replicates]


import unittest
import scipy as SP
import scipy.optimize.optimize as OPT
from pygp.covar import se, combinators
from pygp.gp.basic_gp import GP
from pygp.optimize.optimize import param_dict_to_list, opt_hyper

class TestProductCF(unittest.TestCase):
    
    def setUp(self):
        self.SECF = se.SEARDCF(1)
        self.covar = combinators.ProductCF((self.SECF,self.SECF))
        self.logtheta = SP.log(SP.array([1,3,3,1]))
        x = SP.arange(0,10,1)
        self.x = x[:,SP.newaxis]
        self.y = SP.sin(self.x)
        self.gpr = GP(self.covar,self.x,self.y)

    def test_K(self):
        K_Prod = self.covar.K(self.logtheta,self.x)
        K_SECF1 = self.SECF.K(self.logtheta[:2], self.x)
        K_SECF2 = self.SECF.K(self.logtheta[2:], self.x)
        K_SECF = (K_SECF1 * K_SECF2)
        for i in range(K_Prod.shape[0]):
            for j in range(K_Prod.shape[1]):
                self.assertAlmostEqual(K_Prod[i,j], K_SECF[i,j],7)

    def test_Kd(self):
        Kd_Prod1 = self.covar.Kd(self.logtheta,self.x,0)
        Kd_Prod2 = self.covar.Kd(self.logtheta,self.x,1)

# Path: pygp/covar/se.py
# class SqexpCFARD(CovarianceFunction):
#     def __init__(self,*args,**kwargs):
#     def get_hyperparameter_names(self):
#     def get_number_of_parameters(self):
#     def K(self, theta, x1, x2=None):
#     def Kdiag(self,theta, x1):
#     def Kgrad_theta(self, theta, x1, i):
#     def Kgrad_x(self,theta,x1,x2,d):
#     def Kgrad_xdiag(self,theta,x1,d):
#         V0 = SP.exp(2*theta[0])
#         L  = SP.exp(theta[1:1+self.n_dimensions])
#         V0 = SP.exp(2*theta[0])
#         V0 = SP.exp(2*theta[0])
#         L  = SP.exp(theta[1:1+self.n_dimensions])
#         L2 = SP.exp(2*theta[1:1+self.n_dimensions])
#         RV = SP.zeros([x1.shape[0]])
# 
# Path: pygp/covar/combinators.py
# class SumCF(CovarianceFunction):
# class ProductCF(CovarianceFunction):
# class ShiftCF(CovarianceFunction):
#     def __init__(self, covars, *args, **kw_args):
#     def get_hyperparameter_names(self):
#     def K(self, theta, x1, x2=None):
#     def Kgrad_theta(self, theta, x1, i):
#     def Kgrad_x(self, theta, x1, x2, d):
#     def Kgrad_xdiag(self, theta, x1, d):
#     def __init__(self, covars, *args, **kw_args):
#     def get_hyperparameter_names(self):
#     def K(self, theta, x1, x2=None):
#     def Kgrad_theta(self, theta, x, i):
#     def Kgrad_x(self, theta, x1, x2, d):
#     def Kgrad_xdiag(self, theta, x1, d):
#     def __init__(self, covar, replicate_indices, *args, **kw_args):
#     def get_hyperparameter_names(self):
#     def K(self, theta, x1, x2=None):
#     def Kgrad_theta(self, theta, x, i):
#     def _shift_x(self, x, T):
#             K_ = covar.K(_theta, x1, x2)
#                 K = K_
#         RV = sp.zeros([x1.shape[0], x1.shape[0]])
#         RV = sp.zeros([x1.shape[0]])
#             K = sp.ones([x1.shape[0], x1.shape[0]])
#             K = sp.ones([x1.shape[0], x2.shape[0]])
#         T = theta[covar_n_hyper:covar_n_hyper + self.n_replicates]
#         K = self.covar.K(theta[:covar_n_hyper], shift_x1, x2)
#         T = theta[covar_n_hyper:covar_n_hyper + self.n_replicates]


# Path: exclude-test/test_covar.combinators.py
import unittest
import scipy as SP
import scipy.optimize.optimize as OPT
from pygp.covar import se, combinators
from pygp.gp.basic_gp import GP
from pygp.optimize.optimize import param_dict_to_list, opt_hyper


class TestProductCF(unittest.TestCase):
    
    def setUp(self):
        self.SECF = se.SEARDCF(1)
        self.covar = combinators.ProductCF((self.SECF,self.SECF))
        self.logtheta = SP.log(SP.array([1,3,3,1]))
        x = SP.arange(0,10,1)
        self.x = x[:,SP.newaxis]
        self.y = SP.sin(self.x)
        self.gpr = GP(self.covar,self.x,self.y)

    def test_K(self):
        K_Prod = self.covar.K(self.logtheta,self.x)
        K_SECF1 = self.SECF.K(self.logtheta[:2], self.x)
        K_SECF2 = self.SECF.K(self.logtheta[2:], self.x)
        K_SECF = (K_SECF1 * K_SECF2)
        for i in range(K_Prod.shape[0]):
            for j in range(K_Prod.shape[1]):
                self.assertAlmostEqual(K_Prod[i,j], K_SECF[i,j],7)

    def test_Kd(self):
        Kd_Prod1 = self.covar.Kd(self.logtheta,self.x,0)
        Kd_Prod2 = self.covar.Kd(self.logtheta,self.x,1)

        Kd_Prod3 = self.covar.Kd(self.logtheta,self.x,2)