#NEWLINE# def test_calc_gradient_multiple_params( self ) : #NEWLINE# #INDENT# prob = Problem ( ) #NEWLINE# prob . root = FanIn ( ) #NEWLINE# prob . setup ( check = False ) #NEWLINE# prob . run ( ) #NEWLINE# indep_list = [ 'p1.x1' , 'p2.x2' ] #NEWLINE# unknown_list = [ 'comp3.y' ] #NEWLINE# J = prob . calc_gradient ( indep_list , unknown_list , mode = 'fwd' , return_format = 'dict' ) #NEWLINE# assert_almost_equal ( J [ 'comp3.y' ] [ 'p2.x2' ] , np . array ( [ [ 35.0 ] ] ) ) #NEWLINE# assert_almost_equal ( J [ 'comp3.y' ] [ 'p1.x1' ] , np . array ( [ [ ( - 6.0 ) ] ] ) ) #NEWLINE# J = prob . calc_gradient ( indep_list , unknown_list , mode = 'fwd' , return_format = 'array' ) #NEWLINE# assert_almost_equal ( J , np . array ( [ [ ( - 6.0 ) , 35.0 ] ] ) ) #NEWLINE# J = prob . calc_gradient ( indep_list , unknown_list , mode = 'rev' , return_format = 'dict' ) #NEWLINE# assert_almost_equal ( J [ 'comp3.y' ] [ 'p2.x2' ] , np . array ( [ [ 35.0 ] ] ) ) #NEWLINE# assert_almost_equal ( J [ 'comp3.y' ] [ 'p1.x1' ] , np . array ( [ [ ( - 6.0 ) ] ] ) ) #NEWLINE# J = prob . calc_gradient ( indep_list , unknown_list , mode = 'rev' , return_format = 'array' ) #NEWLINE# assert_almost_equal ( J , np . array ( [ [ ( - 6.0 ) , 35.0 ] ] ) ) #NEWLINE# J = prob . calc_gradient ( indep_list , unknown_list , mode = 'fd' , return_format = 'dict' ) #NEWLINE# assert_almost_equal ( J [ 'comp3.y' ] [ 'p2.x2' ] , np . array ( [ [ 35.0 ] ] ) ) #NEWLINE# assert_almost_equal ( J [ 'comp3.y' ] [ 'p1.x1' ] , np . array ( [ [ ( - 6.0 ) ] ] ) ) #NEWLINE# J = prob . calc_gradient ( indep_list , unknown_list , mode = 'fd' , return_format = 'array' ) #NEWLINE# assert_almost_equal ( J , np . array ( [ [ ( - 6.0 ) , 35.0 ] ] ) )