<s> from __future__ import print_function <EOL> from builtins import range <EOL> import unittest <EOL> import numpy as np <EOL> import pyGPs <EOL> class LikTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . y = np . random . normal ( loc = <NUM_LIT:0.0> , scale = <NUM_LIT:1.0> , size = ( <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> self . mu = np . random . normal ( loc = <NUM_LIT:0.0> , scale = <NUM_LIT:1.0> , size = ( <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> self . s2 = np . random . normal ( loc = <NUM_LIT:0.0> , scale = <NUM_LIT:1.0> , size = ( <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> def checkPrediction ( self , lp , ymu , ys2 ) : <EOL> n , D = self . y . shape <EOL> self . assertTrue ( lp . shape == ( n , D ) ) <EOL> self . assertTrue ( ymu . shape == ( n , D ) ) <EOL> self . assertTrue ( ys2 . shape == ( n , D ) ) <EOL> def checkInferenceLaplace ( self , lp , dlp , d2lp , d3lp ) : <EOL> n , D = self . y . shape <EOL> self . assertTrue ( lp . shape == ( n , D ) ) <EOL> self . assertTrue ( dlp . shape == ( n , D ) ) <EOL> self . assertTrue ( d2lp . shape == ( n , D ) ) <EOL> self . assertTrue ( d3lp . shape == ( n , D ) ) <EOL> def checkDerivativeLaplace ( self , lp , dlp , d2lp ) : <EOL> n , D = self . y . shape <EOL> self . assertTrue ( lp . shape == ( n , D ) ) <EOL> self . assertTrue ( dlp . shape == ( n , D ) ) <EOL> self . assertTrue ( d2lp . shape == ( n , D ) ) <EOL> def checkInferenceEP ( self , lp , dlp , d2lp ) : <EOL> n , D = self . y . shape <EOL> self . assertTrue ( lp . shape == ( n , D ) ) <EOL> self . assertTrue ( dlp . shape == ( n , D ) ) <EOL> self . assertTrue ( d2lp . shape == ( n , D ) ) <EOL> def checkDerivativeEP ( self , dlZhyp ) : <EOL> n , D = self . y . shape <EOL> self . assertTrue ( dlZhyp . shape == ( n , D ) ) <EOL> def checkLikelihood ( self , likelihood ) : <EOL> print ( "<STR_LIT>" ) <EOL> lp , ymu , ys2 = likelihood . evaluate ( y = self . y , mu = self . mu , s2 = self . s2 , nargout = <NUM_LIT:3> ) <EOL> self . checkPrediction ( lp , ymu , ys2 ) <EOL> print ( "<STR_LIT>" ) <EOL> lp , dlp , d2lp , d3lp = likelihood . evaluate ( y = self . y , mu = self . mu , s2 = self . s2 , inffunc = pyGPs . inf . Laplace ( ) , nargout = <NUM_LIT:4> ) <EOL> self . checkInferenceLaplace ( lp , dlp , d2lp , d3lp ) <EOL> for der in range ( len ( likelihood . hyp ) ) : <EOL> lp_dhyp , dlp_dhyp , d2lp_dhyp = likelihood . evaluate ( y = self . y , mu = self . mu , s2 = self . s2 , inffunc = pyGPs . inf . Laplace ( ) , der = der , nargout = <NUM_LIT:4> ) <EOL> self . checkDerivativeLaplace ( lp_dhyp , dlp_dhyp , d2lp_dhyp ) <EOL> print ( "<STR_LIT>" ) <EOL> lp , dlp , d2lp = likelihood . evaluate ( y = self . y , mu = self . mu , s2 = self . s2 , inffunc = pyGPs . inf . EP ( ) , nargout = <NUM_LIT:3> ) <EOL> self . checkInferenceEP ( lp , dlp , d2lp ) <EOL> for der in range ( len ( likelihood . hyp ) ) : <EOL> dlZhyp = likelihood . evaluate ( y = self . y , mu = self . mu , s2 = self . s2 , inffunc = pyGPs . inf . EP ( ) , der = der , nargout = <NUM_LIT:3> ) <EOL> self . checkDerivativeEP ( dlZhyp ) <EOL> def test_likGauss ( self ) : <EOL> print ( "<STR_LIT>" ) <EOL> likelihood = pyGPs . lik . Gauss ( ) <EOL> self . checkLikelihood ( likelihood ) <EOL> def test_likErf ( self ) : <EOL> print ( "<STR_LIT>" ) <EOL> likelihood = pyGPs . lik . Erf ( ) <EOL> self . checkLikelihood ( likelihood ) <EOL> def test_likLaplace ( self ) : <EOL> print ( "<STR_LIT>" ) <EOL> likelihood = pyGPs . lik . Laplace ( ) <EOL> self . checkLikelihood ( likelihood ) <EOL> '''<STR_LIT>''' <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> print ( "<STR_LIT>" ) <EOL> unittest . main ( ) </s>
