<s> import unittest <EOL> import random <EOL> import numpy as np <EOL> from openmdao . lib . surrogatemodels . api import ResponseSurface <EOL> class ResponseSurfaceTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> random . seed ( <NUM_LIT:10> ) <EOL> np . random . seed ( <NUM_LIT:10> ) <EOL> N = <NUM_LIT> <EOL> d = <NUM_LIT:20> <EOL> means = <NUM_LIT> * np . random . randn ( <NUM_LIT:2> , d ) <EOL> self . X_train = np . zeros ( ( N , d ) ) <EOL> self . Y_train = np . zeros ( N ) <EOL> for i in range ( N ) : <EOL> if np . random . random ( ) > <NUM_LIT> : <EOL> y = <NUM_LIT:1> <EOL> else : <EOL> y = <NUM_LIT:0> <EOL> self . X_train [ i , : ] = np . random . random ( d ) + means [ y , : ] <EOL> self . Y_train [ i ] = <NUM_LIT:4> * y - <NUM_LIT:2> <EOL> def test_training ( self ) : <EOL> lr = ResponseSurface ( self . X_train , self . Y_train ) <EOL> training_reconstruction = [ lr . predict ( x ) for x in self . X_train ] <EOL> residual = sum ( [ x - y for x , y in zip ( training_reconstruction , self . Y_train ) ] ) <EOL> self . assertTrue ( residual < <NUM_LIT> ) </s>
