<s> import logging <EOL> import unittest <EOL> import numpy as np <EOL> from scipy . optimize import check_grad <EOL> import GPy <EOL> from robo . models . gpy_model import GPyModel <EOL> from robo . acquisition . pi import PI <EOL> from robo . initial_design . init_random_uniform import init_random_uniform <EOL> logger = logging . getLogger ( __name__ ) <EOL> class PITestCase ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . X_lower = np . array ( [ <NUM_LIT:0> ] ) <EOL> self . X_upper = np . array ( [ <NUM_LIT:1> ] ) <EOL> self . X = init_random_uniform ( self . X_lower , self . X_upper , <NUM_LIT:10> ) <EOL> self . Y = np . sin ( self . X ) <EOL> self . kernel = GPy . kern . RBF ( input_dim = <NUM_LIT:1> ) <EOL> self . model = GPyModel ( self . kernel ) <EOL> self . model . train ( self . X , self . Y ) <EOL> self . pi = PI ( self . model , <EOL> X_upper = self . X_upper , <EOL> X_lower = self . X_lower ) <EOL> def test_general_interface ( self ) : <EOL> X_test = init_random_uniform ( self . X_lower , self . X_upper , <NUM_LIT:10> ) <EOL> a , dadx = self . pi ( X_test , True ) <EOL> assert len ( a . shape ) == <NUM_LIT:2> <EOL> assert a . shape [ <NUM_LIT:0> ] == X_test . shape [ <NUM_LIT:0> ] <EOL> assert a . shape [ <NUM_LIT:1> ] == <NUM_LIT:1> <EOL> assert np . all ( a ) >= <NUM_LIT:0.0> <EOL> assert len ( dadx . shape ) == <NUM_LIT:2> <EOL> assert dadx . shape [ <NUM_LIT:0> ] == X_test . shape [ <NUM_LIT:0> ] <EOL> assert dadx . shape [ <NUM_LIT:1> ] == X_test . shape [ <NUM_LIT:1> ] <EOL> def test_check_grads ( self ) : <EOL> x_ = np . array ( [ [ np . random . rand ( ) ] ] ) <EOL> assert check_grad ( self . pi , lambda x : - self . pi ( x , True ) [ <NUM_LIT:1> ] , x_ ) < <NUM_LIT> <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
