#NEWLINE# def test_array2D( self ) : #NEWLINE# #INDENT# group = Group ( ) #NEWLINE# group . add ( 'x_param' , IndepVarComp ( 'x' , np . ones ( ( 2 , 2 ) ) ) , promotes = [ '*' ] ) #NEWLINE# group . add ( 'mycomp' , ArrayComp2D ( ) , promotes = [ 'x' , 'y' ] ) #NEWLINE# prob = Problem ( impl = impl ) #NEWLINE# prob . root = group #NEWLINE# prob . root . ln_solver = PetscKSP ( ) #NEWLINE# prob . setup ( check = False ) #NEWLINE# prob . run ( ) #NEWLINE# J = prob . calc_gradient ( [ 'x' ] , [ 'y' ] , mode = 'fwd' , return_format = 'dict' ) #NEWLINE# Jbase = prob . root . mycomp . _jacobian_cache #NEWLINE# diff = np . linalg . norm ( ( J [ 'y' ] [ 'x' ] - Jbase [ ( 'y' , 'x' ) ] ) ) #NEWLINE# assert_rel_error ( self , diff , 0.0 , 1e-08 ) #NEWLINE# J = prob . calc_gradient ( [ 'x' ] , [ 'y' ] , mode = 'rev' , return_format = 'dict' ) #NEWLINE# diff = np . linalg . norm ( ( J [ 'y' ] [ 'x' ] - Jbase [ ( 'y' , 'x' ) ] ) ) #NEWLINE# assert_rel_error ( self , diff , 0.0 , 1e-08 )