#NEWLINE# def _test_Z( self , kernel , psi2n = False ) : #NEWLINE# #INDENT# def f( p ) : #NEWLINE# #INDENT# psi0 = kernel . psi0 ( p , self . qX ) #NEWLINE# psi1 = kernel . psi1 ( p , self . qX ) #NEWLINE# psi2 = kernel . psi2 ( p , self . qX ) #NEWLINE# if ( not psi2n ) : #NEWLINE# #INDENT# psi2 = kernel . psi2 ( p , self . qX ) #NEWLINE# return ( ( ( self . w1 * psi0 ) . sum ( ) + ( self . w2 * psi1 ) . sum ( ) ) + ( self . w3 * psi2 ) . sum ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# psi2 = kernel . psi2n ( p , self . qX ) #NEWLINE# return ( ( ( self . w1 * psi0 ) . sum ( ) + ( self . w2 * psi1 ) . sum ( ) ) + ( self . w3n * psi2 ) . sum ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# def df( p ) : #NEWLINE# #INDENT# return kernel . gradients_Z_expectations ( self . w1 , self . w2 , ( self . w3 if ( not psi2n ) else self . w3n ) , p , self . qX ) #NEWLINE# #UNINDENT# from GPy.models import GradientChecker #NEWLINE# m = GradientChecker ( f , df , self . Z . copy ( ) ) #NEWLINE# self . assertTrue ( m . checkgrad ( ) )