#NEWLINE# def test_fd_options_form_precedence( self ) : #NEWLINE# #INDENT# class MyComp ( Component ) : #NEWLINE# #INDENT# def __init__( self ) : #NEWLINE# #INDENT# super ( MyComp , self ) . __init__ ( ) #NEWLINE# self . add_param ( 'x1' , 3.0 ) #NEWLINE# self . add_param ( 'x2' , 3.0 , form = 'central' ) #NEWLINE# self . add_output ( 'y' , 5.5 ) #NEWLINE# #UNINDENT# def solve_nonlinear( self , params , unknowns , resids ) : #NEWLINE# #INDENT# " Doesn't do much. " #NEWLINE# unknowns [ 'y' ] = ( ( 7.0 * ( params [ 'x1' ] ** 2 ) ) + ( 7.0 * ( params [ 'x2' ] ** 2 ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# prob = Problem ( ) #NEWLINE# prob . root = Group ( ) #NEWLINE# comp = prob . root . add ( 'comp' , MyComp ( ) ) #NEWLINE# prob . root . add ( 'p1' , IndepVarComp ( [ ( 'x1' , 3.0 ) , ( 'x2' , 3.0 ) ] ) ) #NEWLINE# prob . root . connect ( 'p1.x1' , 'comp.x1' ) #NEWLINE# prob . root . connect ( 'p1.x2' , 'comp.x2' ) #NEWLINE# comp . fd_options [ 'force_fd' ] = True #NEWLINE# comp . fd_options [ 'form' ] = 'forward' #NEWLINE# prob . setup ( check = False ) #NEWLINE# prob . run ( ) #NEWLINE# J = prob . calc_gradient ( [ 'p1.x1' , 'p1.x2' ] , [ 'comp.y' ] , return_format = 'dict' ) #NEWLINE# x1_err = ( J [ 'comp.y' ] [ 'p1.x1' ] - 42.0 ) #NEWLINE# x2_err = ( J [ 'comp.y' ] [ 'p1.x2' ] - 42.0 ) #NEWLINE# assert_rel_error ( self , x1_err , 7e-06 , 0.1 ) #NEWLINE# assert_rel_error ( self , x2_err , 5.4e-10 , 0.1 )