#NEWLINE# def test_double_arraycomp( self ) : #NEWLINE# #INDENT# group = Group ( ) #NEWLINE# group . add ( 'x_param1' , IndepVarComp ( 'x1' , np . ones ( 2 ) ) , promotes = [ '*' ] ) #NEWLINE# group . add ( 'x_param2' , IndepVarComp ( 'x2' , np . ones ( 2 ) ) , promotes = [ '*' ] ) #NEWLINE# group . add ( 'mycomp' , DoubleArrayComp ( ) , promotes = [ '*' ] ) #NEWLINE# prob = Problem ( impl = impl ) #NEWLINE# prob . root = group #NEWLINE# prob . root . ln_solver = PetscKSP ( ) #NEWLINE# prob . setup ( check = False ) #NEWLINE# prob . run ( ) #NEWLINE# Jbase = group . mycomp . JJ #NEWLINE# J = prob . calc_gradient ( [ 'x1' , 'x2' ] , [ 'y1' , 'y2' ] , mode = 'fwd' , return_format = 'array' ) #NEWLINE# diff = np . linalg . norm ( ( J - Jbase ) ) #NEWLINE# assert_rel_error ( self , diff , 0.0 , 1e-08 ) #NEWLINE# J = prob . calc_gradient ( [ 'x1' , 'x2' ] , [ 'y1' , 'y2' ] , mode = 'fd' , return_format = 'array' ) #NEWLINE# diff = np . linalg . norm ( ( J - prob ) ) #NEWLINE# assert_rel_error ( self , diff , 0.0 , 1e-08 ) #NEWLINE# J = prob . calc_gradient ( [ 'x1' , 'x2' ] , [ 'y1' , 'y2' ] , mode = 'rev' , return_format = 'array' ) #NEWLINE# diff = np . linalg . norm ( ( J - Jbase ) ) #NEWLINE# assert_rel_error ( self , diff , 0.0 , 1e-08 )