# Path: tests/context.py

# 
# Path: tests/context.py

# 
# Path: tests/context.py



import numpy as np
import copy
import pdb
import os
import time
import matplotlib
import matplotlib.pylab as plt
from scipy.optimize import check_grad
from .context import aep
from .context import flatten_dict, unflatten_dict
from .context import PROP_MC, PROP_MM, PROP_LIN
from test_utils import kink, check_grad
    print 'dgprh aep probit nat_param %r stoc %r' % (nat_param, stoc)
    check_grad(params, model, stochastic=stoc, alpha=alpha)


def test_gpssm_linear_aep_gaussian_kink(nat_param=True, stoc=False, prop_mode=PROP_MM):

    N_train = 50
    process_noise = 0.2
    obs_noise = 0.1
    alpha = 0.5
    M = 4
    Q = 1
    D = 1
    (xtrue, x, y) = kink(N_train, process_noise, obs_noise)
    y_train = np.reshape(y, [y.shape[0], 1])
    # TODO nat_param=nat_param
    lvm = aep.SGPSSM(y_train, Q, M, lik='Gaussian', gp_emi=False)
    lvm.optimise(method='adam', alpha=alpha, maxiter=500, adam_lr=0.08)
    params = lvm.get_hypers()

    # # init hypers, inducing points and q(u) params
    # params = lvm.init_hypers(y_train)
    
    print 'gplvm linear emis aep kink nat_param %r stoc %r prop_mode %s' % (nat_param, stoc, prop_mode)
    check_grad(params, lvm, stochastic=stoc, alpha=alpha, prop_mode=prop_mode)


def test_gpssm_gp_aep_gaussian_kink(nat_param=True, stoc=False, prop_mode=PROP_MM):

    N_train = 10

# Path: tests/context.py

# 
# Path: tests/context.py

# 
# Path: tests/context.py



# Path: tests/test_grads_aep.py
import numpy as np
import copy
import pdb
import os
import time
import matplotlib
import matplotlib.pylab as plt
from scipy.optimize import check_grad
from .context import aep
from .context import flatten_dict, unflatten_dict
from .context import PROP_MC, PROP_MM, PROP_LIN
from test_utils import kink, check_grad

    print 'dgprh aep probit nat_param %r stoc %r' % (nat_param, stoc)
    check_grad(params, model, stochastic=stoc, alpha=alpha)


def test_gpssm_linear_aep_gaussian_kink(nat_param=True, stoc=False, prop_mode=PROP_MM):

    N_train = 50
    process_noise = 0.2
    obs_noise = 0.1
    alpha = 0.5
    M = 4
    Q = 1
    D = 1
    (xtrue, x, y) = kink(N_train, process_noise, obs_noise)
    y_train = np.reshape(y, [y.shape[0], 1])
    # TODO nat_param=nat_param
    lvm = aep.SGPSSM(y_train, Q, M, lik='Gaussian', gp_emi=False)
    lvm.optimise(method='adam', alpha=alpha, maxiter=500, adam_lr=0.08)
    params = lvm.get_hypers()

    # # init hypers, inducing points and q(u) params
    # params = lvm.init_hypers(y_train)
    
    print 'gplvm linear emis aep kink nat_param %r stoc %r prop_mode %s' % (nat_param, stoc, prop_mode)
    check_grad(params, lvm, stochastic=stoc, alpha=alpha, prop_mode=prop_mode)


def test_gpssm_gp_aep_gaussian_kink(nat_param=True, stoc=False, prop_mode=PROP_MM):

    N_train = 10

    process_noise = 0.2