<s> """<STR_LIT>""" <EOL> import sys <EOL> import unittest <EOL> import warnings <EOL> from six import text_type , PY3 <EOL> from six . moves import cStringIO <EOL> import numpy as np <EOL> from openmdao . api import Component , Problem , Group , IndepVarComp , ExecComp , LinearGaussSeidel , ScipyGMRES , Driver <EOL> from openmdao . core . mpi_wrap import MPI <EOL> from openmdao . test . example_groups import ExampleGroup , ExampleGroupWithPromotes , ExampleByObjGroup <EOL> from openmdao . test . sellar import SellarStateConnection <EOL> from openmdao . test . simple_comps import SimpleComp , SimpleImplicitComp , RosenSuzuki , FanIn <EOL> from openmdao . util . options import OptionsDictionary <EOL> if PY3 : <EOL> def py3fix ( s ) : <EOL> return s . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> else : <EOL> def py3fix ( s ) : <EOL> return s <EOL> class TestProblem ( unittest . TestCase ) : <EOL> def test_conflicting_connections ( self ) : <EOL> root = Group ( ) <EOL> G2 = root . add ( '<STR_LIT>' , Group ( ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> G2 . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT> ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> G1 = G2 . add ( '<STR_LIT>' , Group ( ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> G1 . add ( '<STR_LIT>' , ExecComp ( '<STR_LIT>' ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> G3 = root . add ( '<STR_LIT>' , Group ( ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> G3 . add ( '<STR_LIT>' , ExecComp ( '<STR_LIT>' ) ) <EOL> G3 . add ( '<STR_LIT>' , ExecComp ( '<STR_LIT>' ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> G3 . connect ( '<STR_LIT>' , '<STR_LIT:x>' ) <EOL> prob = Problem ( root ) <EOL> try : <EOL> prob . setup ( check = False ) <EOL> except Exception as error : <EOL> msg = "<STR_LIT>" <EOL> self . assertTrue ( msg in str ( error ) ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def test_check_promotes ( self ) : <EOL> prob = Problem ( Group ( ) ) <EOL> G = prob . root . add ( '<STR_LIT>' , Group ( ) ) <EOL> C = G . add ( '<STR_LIT:C>' , SimpleComp ( ) , promotes = [ '<STR_LIT>' , '<STR_LIT:y>' ] ) <EOL> with warnings . catch_warnings ( record = True ) as w : <EOL> warnings . simplefilter ( "<STR_LIT:ignore>" ) <EOL> prob . setup ( check = False ) <EOL> prob = Problem ( Group ( ) ) <EOL> G = prob . root . add ( '<STR_LIT>' , Group ( ) ) <EOL> C = G . add ( '<STR_LIT:C>' , SimpleComp ( ) , promotes = [ '<STR_LIT>' ] ) <EOL> try : <EOL> prob . setup ( check = False ) <EOL> except Exception as error : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( text_type ( error ) , msg ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> prob = Problem ( Group ( ) ) <EOL> G = prob . root . add ( '<STR_LIT>' , Group ( ) ) <EOL> P = G . add ( '<STR_LIT:P>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT> ) , promotes = [ '<STR_LIT>' ] ) <EOL> try : <EOL> prob . setup ( check = False ) <EOL> except Exception as error : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( text_type ( error ) , msg ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def test_conflicting_promotions ( self ) : <EOL> root = Group ( ) <EOL> G2 = root . add ( '<STR_LIT>' , Group ( ) ) <EOL> G2 . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT> ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> G1 = G2 . add ( '<STR_LIT>' , Group ( ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> G1 . add ( '<STR_LIT>' , ExecComp ( '<STR_LIT>' ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> G3 = root . add ( '<STR_LIT>' , Group ( ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> G3 . add ( '<STR_LIT>' , ExecComp ( '<STR_LIT>' ) , promotes = [ '<STR_LIT:y>' ] ) <EOL> G3 . add ( '<STR_LIT>' , ExecComp ( '<STR_LIT>' ) , promotes = [ '<STR_LIT:x>' , '<STR_LIT:y>' ] ) <EOL> prob = Problem ( root ) <EOL> try : <EOL> prob . setup ( check = False ) <EOL> except Exception as error : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( text_type ( error ) , msg ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def test_conflicting_promoted_state_vars ( self ) : <EOL> root = Group ( ) <EOL> comp1 = SimpleImplicitComp ( ) <EOL> comp2 = SimpleImplicitComp ( ) <EOL> root . add ( '<STR_LIT>' , comp1 , promotes = [ '<STR_LIT:z>' ] ) <EOL> root . add ( '<STR_LIT>' , comp2 , promotes = [ '<STR_LIT:z>' ] ) <EOL> prob = Problem ( root ) <EOL> with self . assertRaises ( RuntimeError ) as err : <EOL> prob . setup ( check = False ) <EOL> expected_msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err . exception ) , expected_msg ) <EOL> def test_unconnected_param_access ( self ) : <EOL> prob = Problem ( root = Group ( ) ) <EOL> G1 = prob . root . add ( '<STR_LIT>' , Group ( ) ) <EOL> G2 = G1 . add ( '<STR_LIT>' , Group ( ) ) <EOL> C1 = G2 . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) ) <EOL> C2 = G2 . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) ) <EOL> G2 . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> with warnings . catch_warnings ( record = True ) as w : <EOL> warnings . simplefilter ( "<STR_LIT:ignore>" ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> C1 . params [ '<STR_LIT:x>' ] = <NUM_LIT> <EOL> self . assertEqual ( prob [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> prob [ '<STR_LIT>' ] = <NUM_LIT> <EOL> self . assertEqual ( C1 . params [ '<STR_LIT:x>' ] , <NUM_LIT> ) <EOL> def test_unconnected_param_access_with_promotes ( self ) : <EOL> prob = Problem ( root = Group ( ) ) <EOL> G1 = prob . root . add ( '<STR_LIT>' , Group ( ) ) <EOL> G2 = G1 . add ( '<STR_LIT>' , Group ( ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> C1 = G2 . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> C2 = G2 . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) ) <EOL> G2 . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> with warnings . catch_warnings ( record = True ) as w : <EOL> warnings . simplefilter ( "<STR_LIT:ignore>" ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> C1 . params [ '<STR_LIT:x>' ] = <NUM_LIT> <EOL> self . assertEqual ( prob [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( prob . root . G1 . G2 . C1 . params [ '<STR_LIT:x>' ] , <NUM_LIT> ) <EOL> prob [ '<STR_LIT>' ] = <NUM_LIT> <EOL> self . assertEqual ( C1 . params [ '<STR_LIT:x>' ] , <NUM_LIT> ) <EOL> prob [ '<STR_LIT>' ] = <NUM_LIT> <EOL> self . assertEqual ( C1 . params [ '<STR_LIT:x>' ] , <NUM_LIT> ) <EOL> prob [ '<STR_LIT>' ] = <NUM_LIT> <EOL> self . assertEqual ( prob . root . G1 . G2 . C1 . params [ '<STR_LIT:x>' ] , <NUM_LIT> ) <EOL> prob . run ( ) <EOL> def test_input_input_explicit_conns_no_conn ( self ) : <EOL> prob = Problem ( root = Group ( ) ) <EOL> root = prob . root <EOL> root . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT:1.0> ) ) <EOL> root . add ( '<STR_LIT>' , ExecComp ( '<STR_LIT>' ) ) <EOL> root . add ( '<STR_LIT>' , ExecComp ( '<STR_LIT>' ) ) <EOL> root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> with warnings . catch_warnings ( record = True ) as w : <EOL> warnings . simplefilter ( "<STR_LIT:ignore>" ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> self . assertEqual ( root . connections , { } ) <EOL> def test_input_input_explicit_conns_w_conn ( self ) : <EOL> prob = Problem ( root = Group ( ) ) <EOL> root = prob . root <EOL> root . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT:1.0> ) ) <EOL> root . add ( '<STR_LIT>' , ExecComp ( '<STR_LIT>' ) ) <EOL> root . add ( '<STR_LIT>' , ExecComp ( '<STR_LIT>' ) ) <EOL> root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> self . assertEqual ( root . connections [ '<STR_LIT>' ] , ( '<STR_LIT>' , None ) ) <EOL> self . assertEqual ( root . connections [ '<STR_LIT>' ] , ( '<STR_LIT>' , None ) ) <EOL> self . assertEqual ( len ( root . connections ) , <NUM_LIT:2> ) <EOL> def test_explicit_connection_errors ( self ) : <EOL> class A ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( A , self ) . __init__ ( ) <EOL> self . add_state ( '<STR_LIT:x>' , <NUM_LIT:0> ) <EOL> class B ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( B , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT:x>' , <NUM_LIT:0> ) <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . root . add ( '<STR_LIT:A>' , A ( ) ) <EOL> prob . root . add ( '<STR_LIT:B>' , B ( ) ) <EOL> prob . root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> prob . setup ( check = False ) <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . add ( '<STR_LIT:A>' , A ( ) ) <EOL> prob . root . add ( '<STR_LIT:B>' , B ( ) ) <EOL> prob . root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> with self . assertRaises ( Exception ) as cm : <EOL> prob . setup ( check = False ) <EOL> expected = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( str ( cm . exception ) , expected ) <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . add ( '<STR_LIT:A>' , A ( ) ) <EOL> prob . root . add ( '<STR_LIT:B>' , B ( ) ) <EOL> prob . root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> with self . assertRaises ( Exception ) as cm : <EOL> prob . setup ( check = False ) <EOL> expected = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( str ( cm . exception ) , expected ) <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . add ( '<STR_LIT:A>' , A ( ) ) <EOL> prob . root . add ( '<STR_LIT:B>' , B ( ) ) <EOL> prob . root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> with self . assertRaises ( Exception ) as cm : <EOL> prob . setup ( check = False ) <EOL> expected = ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( str ( cm . exception ) , expected ) <EOL> def test_check_connections ( self ) : <EOL> class A ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( A , self ) . __init__ ( ) <EOL> self . add_state ( '<STR_LIT:y>' , np . zeros ( ( <NUM_LIT:2> , ) ) , shape = ( <NUM_LIT:2> , ) ) <EOL> class B ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( B , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT:y>' , np . zeros ( ( <NUM_LIT:3> , ) ) , shape = ( <NUM_LIT:3> , ) ) <EOL> class C ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( C , self ) . __init__ ( ) <EOL> self . add_state ( '<STR_LIT:y>' , np . zeros ( ( <NUM_LIT:2> , ) ) ) <EOL> class D ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( D , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT:y>' , np . zeros ( ( <NUM_LIT:2> , ) ) ) <EOL> class E ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( E , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT:y>' , <NUM_LIT:1.0> ) <EOL> type_err = "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . add ( '<STR_LIT:A>' , A ( ) ) <EOL> prob . root . add ( '<STR_LIT:E>' , E ( ) ) <EOL> prob . root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> with self . assertRaises ( Exception ) as cm : <EOL> prob . setup ( check = False ) <EOL> expected = py3fix ( type_err % ( '<STR_LIT>' , "<STR_LIT>" , '<STR_LIT:float>' , "<STR_LIT>" ) ) <EOL> self . assertEqual ( str ( cm . exception ) , expected ) <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . add ( '<STR_LIT:A>' , A ( ) , promotes = [ '<STR_LIT:y>' ] ) <EOL> prob . root . add ( '<STR_LIT:E>' , E ( ) , promotes = [ '<STR_LIT:y>' ] ) <EOL> with self . assertRaises ( Exception ) as cm : <EOL> prob . setup ( check = False ) <EOL> expected = py3fix ( type_err % ( '<STR_LIT>' , "<STR_LIT>" , '<STR_LIT:float>' , "<STR_LIT>" ) ) <EOL> self . assertEqual ( str ( cm . exception ) , expected ) <EOL> shape_err = "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . add ( '<STR_LIT:A>' , A ( ) ) <EOL> prob . root . add ( '<STR_LIT:B>' , B ( ) ) <EOL> prob . root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> with self . assertRaises ( Exception ) as cm : <EOL> prob . setup ( check = False ) <EOL> raised_error = str ( cm . exception ) <EOL> raised_error = raised_error . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> raised_error = raised_error . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> expected = shape_err % ( '<STR_LIT>' , "<STR_LIT>" , '<STR_LIT>' , "<STR_LIT>" ) <EOL> self . assertTrue ( expected in raised_error ) <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . add ( '<STR_LIT:A>' , A ( ) , promotes = [ '<STR_LIT:y>' ] ) <EOL> prob . root . add ( '<STR_LIT:B>' , B ( ) , promotes = [ '<STR_LIT:y>' ] ) <EOL> with self . assertRaises ( Exception ) as cm : <EOL> prob . setup ( check = False ) <EOL> raised_error = str ( cm . exception ) <EOL> raised_error = raised_error . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> raised_error = raised_error . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> expected = shape_err % ( '<STR_LIT>' , "<STR_LIT>" , '<STR_LIT>' , "<STR_LIT>" ) <EOL> self . assertTrue ( expected in raised_error ) <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . add ( '<STR_LIT:B>' , B ( ) ) <EOL> prob . root . add ( '<STR_LIT:C>' , C ( ) ) <EOL> prob . root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> with self . assertRaises ( Exception ) as cm : <EOL> prob . setup ( check = False ) <EOL> raised_error = str ( cm . exception ) <EOL> raised_error = raised_error . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> raised_error = raised_error . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> expected = shape_err % ( '<STR_LIT>' , "<STR_LIT>" , '<STR_LIT>' , "<STR_LIT>" ) <EOL> self . assertTrue ( expected in raised_error ) <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . add ( '<STR_LIT:B>' , B ( ) , promotes = [ '<STR_LIT:y>' ] ) <EOL> prob . root . add ( '<STR_LIT:C>' , C ( ) , promotes = [ '<STR_LIT:y>' ] ) <EOL> with self . assertRaises ( Exception ) as cm : <EOL> prob . setup ( check = False ) <EOL> raised_error = str ( cm . exception ) <EOL> raised_error = raised_error . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> raised_error = raised_error . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> expected = shape_err % ( '<STR_LIT>' , "<STR_LIT>" , '<STR_LIT>' , "<STR_LIT>" ) <EOL> self . assertTrue ( expected in raised_error ) <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . root . add ( '<STR_LIT:A>' , A ( ) ) <EOL> prob . root . add ( '<STR_LIT:D>' , D ( ) ) <EOL> prob . root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> stream = cStringIO ( ) <EOL> checks = prob . setup ( out_stream = stream ) <EOL> self . assertEqual ( checks [ '<STR_LIT>' ] , [ '<STR_LIT:D>' ] ) <EOL> self . assertEqual ( checks [ '<STR_LIT>' ] , [ ] ) <EOL> content = stream . getvalue ( ) <EOL> self . assertTrue ( "<STR_LIT>" in content ) <EOL> self . assertTrue ( "<STR_LIT>" in content ) <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . root . add ( '<STR_LIT:A>' , A ( ) , promotes = [ '<STR_LIT:y>' ] ) <EOL> prob . root . add ( '<STR_LIT:D>' , D ( ) , promotes = [ '<STR_LIT:y>' ] ) <EOL> stream = cStringIO ( ) <EOL> checks = prob . setup ( out_stream = stream ) <EOL> self . assertEqual ( checks [ '<STR_LIT>' ] , [ '<STR_LIT:D>' ] ) <EOL> self . assertEqual ( checks [ '<STR_LIT>' ] , [ ] ) <EOL> content = stream . getvalue ( ) <EOL> self . assertTrue ( "<STR_LIT>" in content ) <EOL> self . assertTrue ( "<STR_LIT>" in content ) <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . root . add ( '<STR_LIT:C>' , C ( ) ) <EOL> prob . root . add ( '<STR_LIT:D>' , D ( ) ) <EOL> prob . root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> stream = cStringIO ( ) <EOL> checks = prob . setup ( out_stream = stream ) <EOL> self . assertEqual ( checks [ '<STR_LIT>' ] , [ '<STR_LIT:D>' ] ) <EOL> self . assertEqual ( checks [ '<STR_LIT>' ] , [ ] ) <EOL> content = stream . getvalue ( ) <EOL> self . assertTrue ( "<STR_LIT>" in content ) <EOL> self . assertTrue ( "<STR_LIT>" in content ) <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . ln_solver = ScipyGMRES ( ) <EOL> prob . root . add ( '<STR_LIT:C>' , C ( ) , promotes = [ '<STR_LIT:y>' ] ) <EOL> prob . root . add ( '<STR_LIT:D>' , D ( ) , promotes = [ '<STR_LIT:y>' ] ) <EOL> stream = cStringIO ( ) <EOL> checks = prob . setup ( out_stream = stream ) <EOL> self . assertEqual ( checks [ '<STR_LIT>' ] , [ '<STR_LIT:D>' ] ) <EOL> self . assertEqual ( checks [ '<STR_LIT>' ] , [ ] ) <EOL> content = stream . getvalue ( ) <EOL> self . assertTrue ( "<STR_LIT>" in content ) <EOL> self . assertTrue ( "<STR_LIT>" in content ) <EOL> def test_src_idx_gt_src_size ( self ) : <EOL> class A ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( A , self ) . __init__ ( ) <EOL> self . add_state ( '<STR_LIT:y>' , np . zeros ( ( <NUM_LIT:2> , ) ) , shape = ( <NUM_LIT:2> , ) ) <EOL> class B ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( B , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT:x>' , np . zeros ( ( <NUM_LIT:3> , ) ) , shape = ( <NUM_LIT:3> , ) ) <EOL> prob = Problem ( root = Group ( ) ) <EOL> prob . root . add ( "<STR_LIT:A>" , A ( ) ) <EOL> prob . root . add ( "<STR_LIT:B>" , B ( ) ) <EOL> prob . root . connect ( "<STR_LIT>" , "<STR_LIT>" , src_indices = [ <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:2> ] ) <EOL> try : <EOL> prob . setup ( check = False ) <EOL> except Exception as err : <EOL> self . assertEqual ( str ( err ) , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def test_src_idx_neg ( self ) : <EOL> class A ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( A , self ) . __init__ ( ) <EOL> self . add_output ( '<STR_LIT:y>' , np . zeros ( ( <NUM_LIT:5> , ) ) , shape = ( <NUM_LIT:5> , ) ) <EOL> class B ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( B , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT:x>' , np . zeros ( ( <NUM_LIT:3> , ) ) , shape = ( <NUM_LIT:3> , ) ) <EOL> prob = Problem ( root = Group ( ) ) <EOL> prob . root . add ( "<STR_LIT:A>" , A ( ) ) <EOL> prob . root . add ( "<STR_LIT:B>" , B ( ) ) <EOL> prob . root . connect ( "<STR_LIT>" , "<STR_LIT>" , src_indices = [ <NUM_LIT:0> , <NUM_LIT:1> , - <NUM_LIT:1> ] ) <EOL> try : <EOL> prob . setup ( check = False ) <EOL> except Exception as err : <EOL> self . assertTrue ( "<STR_LIT>" in str ( err ) ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def test_src_idx_gt_src_size ( self ) : <EOL> class A ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( A , self ) . __init__ ( ) <EOL> self . add_output ( '<STR_LIT:y>' , np . zeros ( ( <NUM_LIT:5> , ) ) , shape = ( <NUM_LIT:5> , ) ) <EOL> class B ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( B , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT:x>' , np . zeros ( ( <NUM_LIT:3> , ) ) , shape = ( <NUM_LIT:3> , ) ) <EOL> prob = Problem ( root = Group ( ) ) <EOL> prob . root . add ( "<STR_LIT:A>" , A ( ) ) <EOL> prob . root . add ( "<STR_LIT:B>" , B ( ) ) <EOL> prob . root . connect ( "<STR_LIT>" , "<STR_LIT>" , src_indices = [ <NUM_LIT:1> , <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> try : <EOL> prob . setup ( check = False ) <EOL> except Exception as err : <EOL> self . assertTrue ( "<STR_LIT>" <EOL> "<STR_LIT>" in str ( err ) ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def test_simplest_run ( self ) : <EOL> prob = Problem ( root = Group ( ) ) <EOL> root = prob . root <EOL> root . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT> ) ) <EOL> root . add ( '<STR_LIT>' , ExecComp ( '<STR_LIT>' ) ) <EOL> root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> result = root . unknowns [ '<STR_LIT>' ] <EOL> self . assertAlmostEqual ( <NUM_LIT> , result , <NUM_LIT:3> ) <EOL> def test_simplest_run_w_promote ( self ) : <EOL> prob = Problem ( root = Group ( ) ) <EOL> root = prob . root <EOL> root . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT> ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> root . add ( '<STR_LIT>' , ExecComp ( '<STR_LIT>' ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> result = root . unknowns [ '<STR_LIT>' ] <EOL> self . assertAlmostEqual ( <NUM_LIT> , result , <NUM_LIT:3> ) <EOL> def test_variable_access ( self ) : <EOL> prob = Problem ( root = ExampleGroup ( ) ) <EOL> try : <EOL> prob [ '<STR_LIT>' ] <EOL> except Exception as err : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( text_type ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> prob . setup ( check = False ) <EOL> self . assertEqual ( prob [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( prob [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( prob . root . G3 . C3 . params [ '<STR_LIT:x>' ] , <NUM_LIT:0.> ) <EOL> self . assertEqual ( prob . root . G2 . G1 . C2 . params [ '<STR_LIT:x>' ] , <NUM_LIT:0.> ) <EOL> prob = Problem ( root = ExampleGroupWithPromotes ( ) ) <EOL> prob . setup ( check = False ) <EOL> self . assertEqual ( prob . root . G2 . G1 . C2 . params [ '<STR_LIT:x>' ] , <NUM_LIT:0.> ) <EOL> prob [ '<STR_LIT>' ] = <NUM_LIT> <EOL> self . assertEqual ( prob [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> def test_variable_access_before_setup ( self ) : <EOL> prob = Problem ( root = ExampleGroup ( ) ) <EOL> try : <EOL> prob [ '<STR_LIT>' ] = <NUM_LIT> <EOL> except AttributeError as err : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( text_type ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> try : <EOL> prob . run ( ) <EOL> except RuntimeError as err : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( text_type ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_basic_run ( self ) : <EOL> prob = Problem ( root = ExampleGroup ( ) ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> self . assertAlmostEqual ( prob [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> stream = cStringIO ( ) <EOL> prob . root . list_connections ( stream = stream ) <EOL> prob . root . list_connections ( unconnected = False , stream = stream ) <EOL> prob . root . list_connections ( group_by_comp = False , stream = stream ) <EOL> prob . root . G3 . C3 . list_connections ( var = '<STR_LIT:x>' , stream = stream ) <EOL> def test_no_vecs ( self ) : <EOL> prob = Problem ( root = ExampleGroup ( ) ) <EOL> prob . setup ( check = False ) <EOL> try : <EOL> prob . unknowns [ '<STR_LIT>' ] <EOL> except AttributeError as err : <EOL> self . assertEqual ( str ( err ) , "<STR_LIT>" ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> try : <EOL> prob . params [ '<STR_LIT>' ] <EOL> except AttributeError as err : <EOL> self . assertEqual ( str ( err ) , "<STR_LIT>" ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> try : <EOL> prob . resids [ '<STR_LIT>' ] <EOL> except AttributeError as err : <EOL> self . assertEqual ( str ( err ) , "<STR_LIT>" ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> def test_byobj_run ( self ) : <EOL> prob = Problem ( root = ExampleByObjGroup ( ) ) <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> self . assertEqual ( prob [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> def test_scalar_sizes ( self ) : <EOL> class A ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( A , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT:x>' , shape = <NUM_LIT:1> ) <EOL> self . add_output ( '<STR_LIT:y>' , shape = <NUM_LIT:1> ) <EOL> class B ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( B , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT:x>' , shape = <NUM_LIT:2> ) <EOL> self . add_output ( '<STR_LIT:y>' , shape = <NUM_LIT:2> ) <EOL> class C ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( C , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT:x>' , shape = <NUM_LIT:3> ) <EOL> self . add_output ( '<STR_LIT:y>' , shape = <NUM_LIT:3> ) <EOL> prob = Problem ( ) <EOL> root = prob . root = Group ( ) <EOL> root . add ( '<STR_LIT:X>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT:0.> , shape = <NUM_LIT:1> ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> root . add ( '<STR_LIT>' , A ( ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> root . add ( '<STR_LIT>' , A ( ) ) <EOL> root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> prob . setup ( check = False ) <EOL> prob = Problem ( ) <EOL> root = prob . root = Group ( ) <EOL> root . add ( '<STR_LIT:X>' , IndepVarComp ( '<STR_LIT:x>' , np . zeros ( <NUM_LIT:2> ) , shape = <NUM_LIT:2> ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> root . add ( '<STR_LIT>' , B ( ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> root . add ( '<STR_LIT>' , B ( ) ) <EOL> root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> prob . setup ( check = False ) <EOL> prob = Problem ( ) <EOL> root = prob . root = Group ( ) <EOL> root . add ( '<STR_LIT:X>' , IndepVarComp ( '<STR_LIT:x>' , np . zeros ( <NUM_LIT:2> ) , shape = <NUM_LIT:2> ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> root . add ( '<STR_LIT>' , B ( ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> root . add ( '<STR_LIT>' , C ( ) ) <EOL> root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> with self . assertRaises ( Exception ) as cm : <EOL> prob . setup ( check = False ) <EOL> expected = "<STR_LIT>" "<STR_LIT>" <EOL> self . assertTrue ( expected in str ( cm . exception ) ) <EOL> prob = Problem ( ) <EOL> root = prob . root = Group ( ) <EOL> root . add ( '<STR_LIT:X>' , IndepVarComp ( '<STR_LIT:x>' , <NUM_LIT:0.> , shape = <NUM_LIT:1> ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> root . add ( '<STR_LIT>' , B ( ) , promotes = [ '<STR_LIT:x>' ] ) <EOL> with self . assertRaises ( Exception ) as cm : <EOL> prob . setup ( check = False ) <EOL> expected = py3fix ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( expected , str ( cm . exception ) ) <EOL> def test_mode_auto ( self ) : <EOL> prob = Problem ( ) <EOL> root = prob . root = Group ( ) <EOL> root . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:a>' , <NUM_LIT:1.0> ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> root . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:b>' , <NUM_LIT:1.0> ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> root . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' , '<STR_LIT>' ] ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> root . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> mode = prob . _mode ( '<STR_LIT>' , [ '<STR_LIT:a>' ] , [ '<STR_LIT:x>' ] ) <EOL> self . assertEqual ( mode , '<STR_LIT>' ) <EOL> mode = prob . _mode ( '<STR_LIT>' , [ '<STR_LIT:a>' , '<STR_LIT:b>' ] , [ '<STR_LIT:x>' ] ) <EOL> self . assertEqual ( mode , '<STR_LIT>' ) <EOL> OptionsDictionary . locked = False <EOL> root . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> mode = prob . _check_for_parallel_derivs ( [ '<STR_LIT:a>' , '<STR_LIT:b>' ] , [ '<STR_LIT:x>' ] , False , False ) <EOL> self . assertEqual ( mode , '<STR_LIT>' ) <EOL> def test_check_parallel_derivs ( self ) : <EOL> prob = Problem ( ) <EOL> root = prob . root = Group ( ) <EOL> root . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:a>' , <NUM_LIT:1.0> ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> root . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT:b>' , <NUM_LIT:1.0> ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> sub1 = root . add ( '<STR_LIT>' , Group ( ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> sub1 . ln_solver = LinearGaussSeidel ( ) <EOL> sub2 = sub1 . add ( '<STR_LIT>' , Group ( ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> sub2 . add ( '<STR_LIT>' , ExecComp ( [ '<STR_LIT>' , '<STR_LIT>' ] ) , promotes = [ '<STR_LIT:*>' ] ) <EOL> sub2 . ln_solver = LinearGaussSeidel ( ) <EOL> root . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> sub1 . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> sub2 . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . setup ( check = False ) <EOL> prob . run ( ) <EOL> root . ln_solver = LinearGaussSeidel ( ) <EOL> root . ln_solver . options [ '<STR_LIT>' ] = True <EOL> prob . driver . add_desvar ( '<STR_LIT>' , <NUM_LIT:1.0> ) <EOL> prob . driver . add_constraint ( '<STR_LIT:x>' , upper = <NUM_LIT:0.0> ) <EOL> prob . driver . add_constraint ( '<STR_LIT:y>' , upper = <NUM_LIT:0.0> ) <EOL> with warnings . catch_warnings ( record = True ) as w : <EOL> if not MPI : <EOL> warnings . simplefilter ( "<STR_LIT:ignore>" ) <EOL> prob . driver . parallel_derivs ( [ '<STR_LIT:x>' , '<STR_LIT:y>' ] ) <EOL> root . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> sub1 . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . _setup_errors = [ ] <EOL> mode = prob . _check_for_parallel_derivs ( [ '<STR_LIT:a>' ] , [ '<STR_LIT:x>' ] , True , False ) <EOL> msg = "<STR_LIT>" <EOL> self . assertTrue ( msg in prob . _setup_errors [ <NUM_LIT:0> ] ) <EOL> sub1 . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> sub2 . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> prob . _setup_errors = [ ] <EOL> mode = prob . _check_for_parallel_derivs ( [ '<STR_LIT:a>' ] , [ '<STR_LIT:x>' ] , True , False ) <EOL> msg = "<STR_LIT>" <EOL> self . assertTrue ( msg in prob . _setup_errors [ <NUM_LIT:0> ] ) <EOL> sub1 . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> mode = prob . _check_for_parallel_derivs ( [ '<STR_LIT:a>' ] , [ '<STR_LIT:x>' ] , True , False ) <EOL> def test_iprint ( self ) : <EOL> top = Problem ( ) <EOL> top . root = SellarStateConnection ( ) <EOL> top . setup ( check = False ) <EOL> base_stdout = sys . stdout <EOL> try : <EOL> ostream = cStringIO ( ) <EOL> sys . stdout = ostream <EOL> top . run ( ) <EOL> finally : <EOL> sys . stdout = base_stdout <EOL> printed = ostream . getvalue ( ) <EOL> self . assertEqual ( printed , '<STR_LIT>' ) <EOL> top . print_all_convergence ( ) <EOL> try : <EOL> ostream = cStringIO ( ) <EOL> sys . stdout = ostream <EOL> top . run ( ) <EOL> finally : <EOL> sys . stdout = base_stdout <EOL> printed = ostream . getvalue ( ) <EOL> self . assertEqual ( printed . count ( '<STR_LIT>' ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( printed . count ( '<STR_LIT>' ) , <NUM_LIT:4> ) <EOL> self . assertTrue ( '<STR_LIT>' in printed ) <EOL> self . assertTrue ( '<STR_LIT>' in printed ) <EOL> def test_error_change_after_setup ( self ) : <EOL> top = Problem ( ) <EOL> top . root = SellarStateConnection ( ) <EOL> top . setup ( check = False ) <EOL> with self . assertRaises ( RuntimeError ) as err : <EOL> top . root . fd_options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> expected_msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err . exception ) , expected_msg ) <EOL> top = Problem ( ) <EOL> top . root = SellarStateConnection ( ) <EOL> top . setup ( check = False ) <EOL> with self . assertRaises ( RuntimeError ) as err : <EOL> top . root . fd_options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> expected_msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err . exception ) , expected_msg ) <EOL> top = Problem ( ) <EOL> top . root = SellarStateConnection ( ) <EOL> top . setup ( check = False ) <EOL> with self . assertRaises ( RuntimeError ) as err : <EOL> top . root . fd_options [ '<STR_LIT>' ] = True <EOL> expected_msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err . exception ) , expected_msg ) <EOL> top = Problem ( ) <EOL> top . root = SellarStateConnection ( ) <EOL> top . setup ( check = False ) <EOL> with self . assertRaises ( RuntimeError ) as err : <EOL> top . root . ln_solver . options [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> expected_msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err . exception ) , expected_msg ) <EOL> top = Problem ( ) <EOL> top . root = SellarStateConnection ( ) <EOL> top . setup ( check = False ) <EOL> with self . assertRaises ( RuntimeError ) as err : <EOL> top . root . ln_solver . options [ '<STR_LIT>' ] = True <EOL> expected_msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err . exception ) , expected_msg ) <EOL> class TestCheckSetup ( unittest . TestCase ) : <EOL> def test_out_of_order ( self ) : <EOL> prob = Problem ( root = Group ( ) ) <EOL> root = prob . root <EOL> G1 = root . add ( "<STR_LIT>" , Group ( ) ) <EOL> G2 = G1 . add ( "<STR_LIT>" , Group ( ) ) <EOL> C1 = G2 . add ( "<STR_LIT>" , ExecComp ( '<STR_LIT>' ) ) <EOL> C2 = G2 . add ( "<STR_LIT>" , ExecComp ( '<STR_LIT>' ) ) <EOL> C3 = G2 . add ( "<STR_LIT>" , ExecComp ( '<STR_LIT>' ) ) <EOL> G2 . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> G2 . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> G2 . set_order ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> stream = cStringIO ( ) <EOL> checks = prob . setup ( out_stream = stream ) <EOL> self . assertEqual ( checks [ '<STR_LIT>' ] , [ ( '<STR_LIT>' , [ ( '<STR_LIT>' , [ '<STR_LIT>' ] ) ] ) ] ) <EOL> def test_cycle ( self ) : <EOL> prob = Problem ( root = Group ( ) ) <EOL> root = prob . root <EOL> G1 = root . add ( "<STR_LIT>" , Group ( ) ) <EOL> G2 = G1 . add ( "<STR_LIT>" , Group ( ) ) <EOL> G2 . ln_solver = ScipyGMRES ( ) <EOL> C1 = G2 . add ( "<STR_LIT>" , ExecComp ( '<STR_LIT>' ) ) <EOL> C2 = G2 . add ( "<STR_LIT>" , ExecComp ( '<STR_LIT>' ) ) <EOL> C3 = G2 . add ( "<STR_LIT>" , ExecComp ( '<STR_LIT>' ) ) <EOL> G2 . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> G2 . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> G2 . connect ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> G2 . set_order ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> stream = cStringIO ( ) <EOL> checks = prob . setup ( out_stream = stream ) <EOL> auto , _ = G2 . list_auto_order ( ) <EOL> self . assertTrue ( auto == [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] or <EOL> auto == [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] or <EOL> auto == [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> self . assertTrue ( "<STR_LIT>" in <EOL> stream . getvalue ( ) ) <EOL> oo = checks [ '<STR_LIT>' ] <EOL> self . assertEqual ( oo [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> expected = { <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) : '<STR_LIT>' , <EOL> ( '<STR_LIT>' , ) : '<STR_LIT>' , <EOL> ( '<STR_LIT>' , ) : '<STR_LIT>' , <EOL> } <EOL> for node , afters in oo [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] : <EOL> self . assertEqual ( node , expected [ tuple ( afters ) ] ) <EOL> def test_pbo_messages ( self ) : <EOL> class PBOSrcComp ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( PBOSrcComp , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT>' , <NUM_LIT> ) <EOL> self . add_output ( '<STR_LIT>' , <NUM_LIT> , units = '<STR_LIT>' , pass_by_obj = True ) <EOL> self . fd_options [ '<STR_LIT>' ] = True <EOL> def solve_nonlinear ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> unknowns [ '<STR_LIT>' ] = params [ '<STR_LIT>' ] <EOL> class PBOTgtCompF ( Component ) : <EOL> def __init__ ( self ) : <EOL> super ( PBOTgtCompF , self ) . __init__ ( ) <EOL> self . add_param ( '<STR_LIT>' , <NUM_LIT> , units = '<STR_LIT>' , pass_by_obj = True ) <EOL> self . add_output ( '<STR_LIT>' , <NUM_LIT> ) <EOL> self . fd_options [ '<STR_LIT>' ] = True <EOL> def solve_nonlinear ( self , params , unknowns , resids ) : <EOL> """<STR_LIT>""" <EOL> unknowns [ '<STR_LIT>' ] = params [ '<STR_LIT>' ] <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . add ( '<STR_LIT:src>' , PBOSrcComp ( ) ) <EOL> prob . root . add ( '<STR_LIT>' , PBOTgtCompF ( ) ) <EOL> prob . root . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT>' , <NUM_LIT> ) , promotes = [ '<STR_LIT>' ] ) <EOL> prob . root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> prob . root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> stream = cStringIO ( ) <EOL> checks = prob . setup ( out_stream = stream ) <EOL> self . assertEqual ( checks [ '<STR_LIT>' ] , [ ] ) <EOL> class GradDriver ( Driver ) : <EOL> def __init__ ( self ) : <EOL> super ( GradDriver , self ) . __init__ ( ) <EOL> self . supports [ '<STR_LIT>' ] = True <EOL> prob = Problem ( ) <EOL> prob . root = Group ( ) <EOL> prob . root . add ( '<STR_LIT:src>' , PBOSrcComp ( ) ) <EOL> prob . root . add ( '<STR_LIT>' , PBOTgtCompF ( ) ) <EOL> prob . root . add ( '<STR_LIT>' , PBOTgtCompF ( ) ) <EOL> prob . root . add ( '<STR_LIT>' , IndepVarComp ( '<STR_LIT>' , <NUM_LIT> ) , promotes = [ '<STR_LIT>' ] ) <EOL> prob . root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> prob . root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> prob . root . connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> prob . driver = GradDriver ( ) <EOL> stream = cStringIO ( ) <EOL> checks = prob . setup ( out_stream = stream ) <EOL> self . assertEqual ( checks [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
