#NEWLINE# def summary_top( results , title = None , gleft = None , gright = None , yname = None , xname = None ) : #NEWLINE# #INDENT# 'generate top table(s)\n\n\n    TODO: this still uses predefined model_methods\n    ? allow gleft, gright to be 1 element tuples instead of filling with None?\n\n    ' #NEWLINE# ( gen_left , gen_right ) = ( gleft , gright ) #NEWLINE# import time #NEWLINE# time_now = time . localtime ( ) #NEWLINE# time_of_day = [ time . strftime ( '%H:%M:%S' , time_now ) ] #NEWLINE# date = time . strftime ( '%a, %d %b %Y' , time_now ) #NEWLINE# ( yname , xname ) = _getnames ( gen_stubs_right , yname = yname , xname = xname ) #NEWLINE# default_items = dict ( [ ( 'Dependent Variable:' , ( lambda : [ yname ] ) ) , ( 'Dep. Variable:' , ( lambda : [ yname ] ) ) , ( 'Model:' , ( lambda : [ results . model . __class__ . __name__ ] ) ) , ( 'Date:' , ( lambda : [ date ] ) ) , ( 'Time:' , ( lambda : time_of_day ) ) , ( 'Number of Obs:' , ( lambda : [ results . nobs ] ) ) , ( 'No. Observations:' , ( lambda : [ ( '%#6d' % results . nobs ) ] ) ) , ( 'Df Model:' , ( lambda : [ ( '%#6d' % results . df_model ) ] ) ) , ( 'Df Residuals:' , ( lambda : [ ( '%#6d' % results . df_resid ) ] ) ) , ( 'Log-Likelihood:' , ( lambda : [ ( '%#8.5g' % results . llf ) ] ) ) ] ) #NEWLINE# if ( title is None ) : #NEWLINE# #INDENT# title = ( results . model . __class__ . __name__ + 'Regression Results' ) #NEWLINE# #UNINDENT# if ( gen_left is None ) : #NEWLINE# #INDENT# gen_left = [ ( 'Dep. Variable:' , None ) , ( 'Model type:' , None ) , ( 'Date:' , None ) , ( 'No. Observations:' , None ) , ( 'Df model:' , None ) , ( 'Df resid:' , None ) ] #NEWLINE# try : #NEWLINE# #INDENT# llf = results . llf #NEWLINE# gen_left . append ( ( 'Log-Likelihood' , None ) ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# gen_right = [ ] #NEWLINE# #UNINDENT# gen_title = title #NEWLINE# gen_header = None #NEWLINE# gen_left_ = [ ] #NEWLINE# for ( item , value ) in gen_left : #NEWLINE# #INDENT# if ( value is None ) : #NEWLINE# #INDENT# value = default_items [ item ] ( ) #NEWLINE# #UNINDENT# gen_left_ . append ( ( item , value ) ) #NEWLINE# #UNINDENT# gen_left = gen_left_ #NEWLINE# if gen_right : #NEWLINE# #INDENT# gen_right_ = [ ] #NEWLINE# for ( item , value ) in gen_right : #NEWLINE# #INDENT# if ( value is None ) : #NEWLINE# #INDENT# value = default_items [ item ] ( ) #NEWLINE# #UNINDENT# gen_right_ . append ( ( item , value ) ) #NEWLINE# #UNINDENT# gen_right = gen_right_ #NEWLINE# #UNINDENT# missing_values = [ k for ( k , v ) in ( gen_left + gen_right ) if ( v is None ) ] #NEWLINE# assert ( missing_values == [ ] ) , missing_values #NEWLINE# if gen_right : #NEWLINE# #INDENT# if ( len ( gen_right ) < len ( gen_left ) ) : #NEWLINE# #INDENT# gen_right += ( [ ( ' ' , ' ' ) ] * ( len ( gen_left ) - len ( gen_right ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( gen_right ) > len ( gen_left ) ) : #NEWLINE# #INDENT# gen_left += ( [ ( ' ' , ' ' ) ] * ( len ( gen_right ) - len ( gen_left ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# gen_right = [ ( ( '%-21s' % ( '  ' + k ) ) , v ) for ( k , v ) in gen_right ] #NEWLINE# ( gen_stubs_right , gen_data_right ) = zip_longest ( * gen_right ) #NEWLINE# gen_table_right = SimpleTable ( gen_data_right , gen_header , gen_stubs_right , title = gen_title , txt_fmt = fmt_2cols ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# gen_table_right = [ ] #NEWLINE# #UNINDENT# ( gen_stubs_left , gen_data_left ) = zip_longest ( * gen_left ) #NEWLINE# gen_table_left = SimpleTable ( gen_data_left , gen_header , gen_stubs_left , title = gen_title , txt_fmt = fmt_2cols ) #NEWLINE# gen_table_left . extend_right ( gen_table_right ) #NEWLINE# general_table = gen_table_left #NEWLINE# return general_table