<s> """<STR_LIT>""" <EOL> import os <EOL> import openmdao . lib . optproblems <EOL> import openmdao . lib . architectures <EOL> from openmdao . lib . casehandlers . api import DBCaseRecorder <EOL> from openmdao . main . api import set_as_top <EOL> from openmdao . main import component <EOL> from openmdao . util . dep import PythonSourceTreeAnalyser <EOL> def build_arch_list ( include = [ ] , exclude = [ ] ) : <EOL> """<STR_LIT>""" <EOL> if include and exclude : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> startdirs = [ os . path . dirname ( openmdao . lib . architectures . __file__ ) , <EOL> os . path . dirname ( component . __file__ ) ] <EOL> psta = PythonSourceTreeAnalyser ( startdirs , os . path . join ( '<STR_LIT:*>' , '<STR_LIT:test>' , '<STR_LIT:*>' ) ) <EOL> architectures = psta . find_inheritors ( "<STR_LIT>" ) <EOL> archs = [ ] <EOL> for arch_name in architectures : <EOL> arch_class = arch_name . split ( "<STR_LIT:.>" ) [ - <NUM_LIT:1> ] <EOL> arch_package = "<STR_LIT:.>" . join ( arch_name . split ( "<STR_LIT:.>" ) [ : - <NUM_LIT:1> ] ) <EOL> if ( not include and not exclude ) or ( include and arch_class in include ) or ( exclude and arch_class not in exclude ) : <EOL> arch_package = __import__ ( arch_package , globals ( ) , locals ( ) , [ arch_class , ] , - <NUM_LIT:1> ) <EOL> archs . append ( getattr ( arch_package , arch_class ) ( ) ) <EOL> return archs <EOL> def build_optproblem_list ( include = [ ] , exclude = [ ] ) : <EOL> """<STR_LIT>""" <EOL> if include and exclude : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> startdirs = [ os . path . dirname ( openmdao . lib . optproblems . __file__ ) , <EOL> os . path . dirname ( component . __file__ ) ] <EOL> psta = PythonSourceTreeAnalyser ( startdirs , os . path . join ( '<STR_LIT:*>' , '<STR_LIT:test>' , '<STR_LIT:*>' ) ) <EOL> opt_problems = psta . find_inheritors ( "<STR_LIT>" ) <EOL> probs = [ ] <EOL> for prob_name in opt_problems : <EOL> prob_class = prob_name . split ( "<STR_LIT:.>" ) [ - <NUM_LIT:1> ] <EOL> prob_package = "<STR_LIT:.>" . join ( prob_name . split ( "<STR_LIT:.>" ) [ : - <NUM_LIT:1> ] ) <EOL> if ( not include and not exclude ) or ( include and prob_class in include ) or ( exclude and prob_class not in exclude ) : <EOL> prob_package = __import__ ( prob_package , globals ( ) , locals ( ) , [ prob_class , ] , - <NUM_LIT:1> ) <EOL> probs . append ( getattr ( prob_package , prob_class ) ( ) ) <EOL> return probs <EOL> def run_arch_test_suite ( arch = [ ] , optproblems = [ ] ) : <EOL> """<STR_LIT>""" <EOL> compat_data = { } <EOL> for p in optproblems : <EOL> arch_data = { } <EOL> prob_name = p . __class__ . __name__ <EOL> converge_file = open ( '<STR_LIT>' % prob_name , '<STR_LIT:w>' ) <EOL> for a in arch : <EOL> prob = set_as_top ( p . __class__ ( ) ) <EOL> arch_name = a . __class__ . __name__ <EOL> prob . architecture = a . __class__ ( ) <EOL> recorders = [ DBCaseRecorder ( ) ] <EOL> prob . architecture . data_recorders = recorders <EOL> print "<STR_LIT>" % ( arch_name , prob_name ) , "<STR_LIT>" , <EOL> try : <EOL> prob . check_config ( ) <EOL> arch_data [ p ] = True <EOL> except RuntimeError : <EOL> arch_data [ p ] = False <EOL> print "<STR_LIT>" <EOL> continue <EOL> prob . run ( ) <EOL> print "<STR_LIT>" <EOL> des_vars = prob . get_des_vars_by_comp ( ) <EOL> print "<STR_LIT>" <EOL> for comp_name in des_vars : <EOL> comp = prob . get ( comp_name ) <EOL> print "<STR_LIT>" % ( comp_name , comp . exec_count , comp . derivative_exec_count ) <EOL> print "<STR_LIT>" <EOL> for k , v in prob . check_solution ( ) . iteritems ( ) : <EOL> print "<STR_LIT:U+0020>" , k , "<STR_LIT>" , v <EOL> iter_data = prob . architecture . data_recorders [ <NUM_LIT:0> ] . get_iterator ( ) <EOL> data = [ case [ '<STR_LIT>' ] for case in iter_data ] <EOL> print >> converge_file , '<STR_LIT>' % ( arch_name , str ( data ) ) <EOL> print <EOL> compat_data [ a ] = arch_data <EOL> return compat_data <EOL> def cli_arch_test_suite ( parser = None , options = None , args = None ) : <EOL> """<STR_LIT>""" <EOL> if not parser : <EOL> return <EOL> if options . inc_arch and options . excl_arch : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> if options . inc_prob and options . excl_prob : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> archs = build_arch_list ( include = options . inc_arch , exclude = options . excl_arch ) <EOL> probs = build_optproblem_list ( include = options . inc_prob , exclude = options . excl_prob ) <EOL> data = run_arch_test_suite ( archs , probs ) <EOL> cli_arch_test_suite . __test__ = False <EOL> run_arch_test_suite . __test__ = False <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> archs = build_arch_list ( include = [ '<STR_LIT>' , ] ) <EOL> probs = build_optproblem_list ( include = [ "<STR_LIT>" ] ) <EOL> data = run_arch_test_suite ( archs , probs ) </s>
