<s> """<STR_LIT>""" <EOL> import unittest <EOL> import numpy as np <EOL> from openmdao . api import Group , Problem , IndepVarComp , ScipyGMRES , DirectSolver , ExecComp , LinearGaussSeidel , AnalysisError <EOL> from openmdao . test . converge_diverge import ConvergeDiverge , SingleDiamond , ConvergeDivergeGroups , SingleDiamondGrouped <EOL> from openmdao . test . sellar import SellarDerivativesGrouped <EOL> from openmdao . test . simple_comps import SimpleCompDerivMatVec , FanOut , FanIn , FanOutGrouped , DoubleArrayComp , FanInGrouped , ArrayComp2D , FanOutAllGrouped <EOL> from openmdao . test . util import assert_rel_error <EOL> from openmdao . util . options import OptionsDictionary <EOL> class TestScipyGMRES ( unittest . TestCase ) : <EOL> def test_simple_matvec ( self ) : <EOL> group = Group ( ) <EOL> group . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT:1.0> ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> group . add ( '<STR_LIT>' , SimpleCompDerivMatVec ( ) , promotes = [ '<STR_LIT:x>' , '<STR_LIT:y>' ] ) <EOL> prob = Problem ( ) <EOL> prob . root = group <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT:x>' ] , [ '<STR_LIT:y>' ] , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT:y>' ] [ '<STR_LIT:x>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT:x>' ] , [ '<STR_LIT:y>' ] , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT:y>' ] [ '<STR_LIT:x>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_simple_matvec_subbed ( self ) : <EOL> group = Group ( ) <EOL> group . add ( '<STR_LIT>' , SimpleCompDerivMatVec ( ) , promotes = [ '<STR_LIT:x>' , '<STR_LIT:y>' ] ) <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT:1.0> ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> prob . root . add ( '<STR_LIT>' , group , promotes = [ '<STR_LIT:*>' ] ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT:x>' ] , [ '<STR_LIT:y>' ] , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT:y>' ] [ '<STR_LIT:x>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT:x>' ] , [ '<STR_LIT:y>' ] , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT:y>' ] [ '<STR_LIT:x>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT:x>' ] , [ '<STR_LIT:y>' ] , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT:y>' ] [ '<STR_LIT:x>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_simple_matvec_subbed_like_multipoint ( self ) : <EOL> group = Group ( ) <EOL> group . add ( '<STR_LIT>' , SimpleCompDerivMatVec ( ) , promotes = [ '<STR_LIT:x>' , '<STR_LIT:y>' ] ) <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . add ( '<STR_LIT>' , group , promotes = [ '<STR_LIT:*>' ] ) <EOL> prob . root . sub . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT:1.0> ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT:x>' ] , [ '<STR_LIT:y>' ] , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT:y>' ] [ '<STR_LIT:x>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT:x>' ] , [ '<STR_LIT:y>' ] , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT:y>' ] [ '<STR_LIT:x>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT:x>' ] , [ '<STR_LIT:y>' ] , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT:y>' ] [ '<STR_LIT:x>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT:x>' ] , [ '<STR_LIT:y>' ] , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_array2D ( self ) : <EOL> group = Group ( ) <EOL> group . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:x>' , np . ones ( ( <NUM_LIT:2> , <NUM_LIT:2> ) ) ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> group . add ( '<STR_LIT>' , ArrayComp2D ( ) , promotes = [ '<STR_LIT:x>' , '<STR_LIT:y>' ] ) <EOL> prob = Problem ( ) <EOL> prob . root = group <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT:x>' ] , [ '<STR_LIT:y>' ] , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> Jbase = prob . root . mycomp . _jacobian_cache <EOL> diff = np . linalg . norm ( J [ '<STR_LIT:y>' ] [ '<STR_LIT:x>' ] - Jbase [ '<STR_LIT:y>' , '<STR_LIT:x>' ] ) <EOL> assert_rel_error ( self , diff , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT:x>' ] , [ '<STR_LIT:y>' ] , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> diff = np . linalg . norm ( J [ '<STR_LIT:y>' ] [ '<STR_LIT:x>' ] - Jbase [ '<STR_LIT:y>' , '<STR_LIT:x>' ] ) <EOL> assert_rel_error ( self , diff , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> def test_double_arraycomp ( self ) : <EOL> group = Group ( ) <EOL> group . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT>' , np . ones ( ( <NUM_LIT:2> ) ) ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> group . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT>' , np . ones ( ( <NUM_LIT:2> ) ) ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> group . add ( '<STR_LIT>' , DoubleArrayComp ( ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> prob = Problem ( ) <EOL> prob . root = group <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> Jbase = group . mycomp . JJ <EOL> J = prob . calc_gradient ( [ '<STR_LIT>' , '<STR_LIT>' ] , [ '<STR_LIT>' , '<STR_LIT>' ] , mode = '<STR_LIT>' , <EOL> return_format = '<STR_LIT>' ) <EOL> diff = np . linalg . norm ( J - Jbase ) <EOL> assert_rel_error ( self , diff , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT>' , '<STR_LIT>' ] , [ '<STR_LIT>' , '<STR_LIT>' ] , mode = '<STR_LIT>' , <EOL> return_format = '<STR_LIT>' ) <EOL> diff = np . linalg . norm ( J - Jbase ) <EOL> assert_rel_error ( self , diff , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT>' , '<STR_LIT>' ] , [ '<STR_LIT>' , '<STR_LIT>' ] , mode = '<STR_LIT>' , <EOL> return_format = '<STR_LIT>' ) <EOL> diff = np . linalg . norm ( J - Jbase ) <EOL> assert_rel_error ( self , diff , <NUM_LIT:0.0> , <NUM_LIT> ) <EOL> def test_simple_in_group_matvec ( self ) : <EOL> group = Group ( ) <EOL> sub = group . add ( '<STR_LIT>' , Group ( ) , promotes = [ '<STR_LIT:x>' , '<STR_LIT:y>' ] ) <EOL> group . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT:1.0> ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> sub . add ( '<STR_LIT>' , SimpleCompDerivMatVec ( ) , promotes = [ '<STR_LIT:x>' , '<STR_LIT:y>' ] ) <EOL> prob = Problem ( ) <EOL> prob . root = group <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT:x>' ] , [ '<STR_LIT:y>' ] , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT:y>' ] [ '<STR_LIT:x>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT:x>' ] , [ '<STR_LIT:y>' ] , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT:y>' ] [ '<STR_LIT:x>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_simple_jac ( self ) : <EOL> group = Group ( ) <EOL> group . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT:1.0> ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> group . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' ] ) , promotes = [ '<STR_LIT:x>' , '<STR_LIT:y>' ] ) <EOL> prob = Problem ( ) <EOL> prob . root = group <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT:x>' ] , [ '<STR_LIT:y>' ] , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT:y>' ] [ '<STR_LIT:x>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( [ '<STR_LIT:x>' ] , [ '<STR_LIT:y>' ] , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT:y>' ] [ '<STR_LIT:x>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_fan_out ( self ) : <EOL> prob = Problem ( ) <EOL> prob . root = FanOut ( ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> indep_list = [ '<STR_LIT>' ] <EOL> unknown_list = [ '<STR_LIT>' , "<STR_LIT>" ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_fan_out_grouped ( self ) : <EOL> prob = Problem ( ) <EOL> prob . root = FanOutGrouped ( ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> indep_list = [ '<STR_LIT>' ] <EOL> unknown_list = [ '<STR_LIT>' , "<STR_LIT>" ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_fan_in ( self ) : <EOL> prob = Problem ( ) <EOL> prob . root = FanIn ( ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> indep_list = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> unknown_list = [ '<STR_LIT>' ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_fan_in_grouped ( self ) : <EOL> prob = Problem ( ) <EOL> prob . root = FanInGrouped ( ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> indep_list = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> unknown_list = [ '<STR_LIT>' ] <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> def test_converge_diverge ( self ) : <EOL> prob = Problem ( ) <EOL> prob . root = ConvergeDiverge ( ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> indep_list = [ '<STR_LIT>' ] <EOL> unknown_list = [ '<STR_LIT>' ] <EOL> prob . run ( ) <EOL> assert_rel_error ( self , prob [ '<STR_LIT>' ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> def test_analysis_error ( self ) : <EOL> prob = Problem ( ) <EOL> prob . root = ConvergeDiverge ( ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . root . ln_solver . options [ '<STR_LIT>' ] = <NUM_LIT:2> <EOL> prob . root . ln_solver . options [ '<STR_LIT>' ] = True <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> indep_list = [ '<STR_LIT>' ] <EOL> unknown_list = [ '<STR_LIT>' ] <EOL> prob . run ( ) <EOL> assert_rel_error ( self , prob [ '<STR_LIT>' ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> try : <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> except AnalysisError as err : <EOL> self . assertEqual ( str ( err ) , "<STR_LIT>" ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def test_converge_diverge_groups ( self ) : <EOL> prob = Problem ( ) <EOL> prob . root = ConvergeDivergeGroups ( ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> assert_rel_error ( self , prob [ '<STR_LIT>' ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> indep_list = [ '<STR_LIT>' ] <EOL> unknown_list = [ '<STR_LIT>' ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> def test_single_diamond ( self ) : <EOL> prob = Problem ( ) <EOL> prob . root = SingleDiamond ( ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> indep_list = [ '<STR_LIT>' ] <EOL> unknown_list = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> def test_single_diamond_grouped ( self ) : <EOL> prob = Problem ( ) <EOL> prob . root = SingleDiamondGrouped ( ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> indep_list = [ '<STR_LIT>' ] <EOL> unknown_list = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> def test_sellar_derivs_grouped ( self ) : <EOL> prob = Problem ( ) <EOL> prob . root = SellarDerivativesGrouped ( ) <EOL> prob . root . mda . nl_solver . options [ '<STR_LIT>' ] = <NUM_LIT> <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> assert_rel_error ( self , prob [ '<STR_LIT>' ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , prob [ '<STR_LIT>' ] , <NUM_LIT> , <NUM_LIT> ) <EOL> indep_list = [ '<STR_LIT:x>' , '<STR_LIT:z>' ] <EOL> unknown_list = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> Jbase = { } <EOL> Jbase [ '<STR_LIT>' ] = { } <EOL> Jbase [ '<STR_LIT>' ] [ '<STR_LIT:x>' ] = - <NUM_LIT> <EOL> Jbase [ '<STR_LIT>' ] [ '<STR_LIT:z>' ] = np . array ( [ - <NUM_LIT> , - <NUM_LIT> ] ) <EOL> Jbase [ '<STR_LIT>' ] = { } <EOL> Jbase [ '<STR_LIT>' ] [ '<STR_LIT:x>' ] = <NUM_LIT> <EOL> Jbase [ '<STR_LIT>' ] [ '<STR_LIT:z>' ] = np . array ( [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> Jbase [ '<STR_LIT>' ] = { } <EOL> Jbase [ '<STR_LIT>' ] [ '<STR_LIT:x>' ] = <NUM_LIT> <EOL> Jbase [ '<STR_LIT>' ] [ '<STR_LIT:z>' ] = np . array ( [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> for key1 , val1 in Jbase . items ( ) : <EOL> for key2 , val2 in val1 . items ( ) : <EOL> assert_rel_error ( self , J [ key1 ] [ key2 ] , val2 , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> for key1 , val1 in Jbase . items ( ) : <EOL> for key2 , val2 in val1 . items ( ) : <EOL> assert_rel_error ( self , J [ key1 ] [ key2 ] , val2 , <NUM_LIT> ) <EOL> OptionsDictionary . locked = False <EOL> prob . root . fd_options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> for key1 , val1 in Jbase . items ( ) : <EOL> for key2 , val2 in val1 . items ( ) : <EOL> assert_rel_error ( self , J [ key1 ] [ key2 ] , val2 , <NUM_LIT> ) <EOL> def test_generate_numpydocstring ( self ) : <EOL> group = Group ( ) <EOL> group . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT:1.0> ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> group . add ( '<STR_LIT>' , SimpleCompDerivMatVec ( ) , promotes = [ '<STR_LIT:x>' , '<STR_LIT:y>' ] ) <EOL> prob = Problem ( ) <EOL> prob . root = group <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> test_string = prob . root . ln_solver . generate_docstring ( ) <EOL> original_string = """<STR_LIT>""" <EOL> for sorig , stest in zip ( original_string . split ( '<STR_LIT:\n>' ) , test_string . split ( '<STR_LIT:\n>' ) ) : <EOL> self . assertEqual ( sorig , stest ) <EOL> class TestScipyGMRESPreconditioner ( unittest . TestCase ) : <EOL> def test_sellar_derivs_grouped_precon ( self ) : <EOL> prob = Problem ( ) <EOL> prob . root = SellarDerivativesGrouped ( ) <EOL> prob . root . mda . nl_solver . options [ '<STR_LIT>' ] = <NUM_LIT> <EOL> prob . root . ln_solver . preconditioner = LinearGaussSeidel ( ) <EOL> prob . root . mda . ln_solver = DirectSolver ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> assert_rel_error ( self , prob [ '<STR_LIT>' ] , <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , prob [ '<STR_LIT>' ] , <NUM_LIT> , <NUM_LIT> ) <EOL> indep_list = [ '<STR_LIT:x>' , '<STR_LIT:z>' ] <EOL> unknown_list = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> Jbase = { } <EOL> Jbase [ '<STR_LIT>' ] = { } <EOL> Jbase [ '<STR_LIT>' ] [ '<STR_LIT:x>' ] = - <NUM_LIT> <EOL> Jbase [ '<STR_LIT>' ] [ '<STR_LIT:z>' ] = np . array ( [ - <NUM_LIT> , - <NUM_LIT> ] ) <EOL> Jbase [ '<STR_LIT>' ] = { } <EOL> Jbase [ '<STR_LIT>' ] [ '<STR_LIT:x>' ] = <NUM_LIT> <EOL> Jbase [ '<STR_LIT>' ] [ '<STR_LIT:z>' ] = np . array ( [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> Jbase [ '<STR_LIT>' ] = { } <EOL> Jbase [ '<STR_LIT>' ] [ '<STR_LIT:x>' ] = <NUM_LIT> <EOL> Jbase [ '<STR_LIT>' ] [ '<STR_LIT:z>' ] = np . array ( [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> for key1 , val1 in Jbase . items ( ) : <EOL> for key2 , val2 in val1 . items ( ) : <EOL> assert_rel_error ( self , J [ key1 ] [ key2 ] , val2 , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> for key1 , val1 in Jbase . items ( ) : <EOL> for key2 , val2 in val1 . items ( ) : <EOL> assert_rel_error ( self , J [ key1 ] [ key2 ] , val2 , <NUM_LIT> ) <EOL> def test_converge_diverge_groups ( self ) : <EOL> prob = Problem ( ) <EOL> prob . root = ConvergeDivergeGroups ( ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . root . ln_solver . preconditioner = LinearGaussSeidel ( ) <EOL> prob . root . sub1 . ln_solver = DirectSolver ( ) <EOL> prob . root . sub3 . ln_solver = DirectSolver ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> assert_rel_error ( self , prob [ '<STR_LIT>' ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> indep_list = [ '<STR_LIT>' ] <EOL> unknown_list = [ '<STR_LIT>' ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> def test_fan_out_all_grouped ( self ) : <EOL> prob = Problem ( ) <EOL> prob . root = FanOutAllGrouped ( ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . root . ln_solver . preconditioner = LinearGaussSeidel ( ) <EOL> prob . root . sub1 . ln_solver = DirectSolver ( ) <EOL> prob . root . sub2 . ln_solver = DirectSolver ( ) <EOL> prob . root . sub3 . ln_solver = DirectSolver ( ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> indep_list = [ '<STR_LIT>' ] <EOL> unknown_list = [ '<STR_LIT>' , "<STR_LIT>" ] <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> J = prob . calc_gradient ( indep_list , unknown_list , mode = '<STR_LIT>' , return_format = '<STR_LIT>' ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , - <NUM_LIT> , <NUM_LIT> ) <EOL> assert_rel_error ( self , J [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <NUM_LIT> , <NUM_LIT> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
