#NEWLINE# def generic_2d( self , expr , typ ) : #NEWLINE# #INDENT# ast = parser . suite ( expr ) #NEWLINE# arg_list = harvest_variables ( ast . tolist ( ) ) #NEWLINE# all_sizes = [ ( 10 , 10 ) , ( 50 , 50 ) , ( 100 , 100 ) , ( 500 , 500 ) , ( 1000 , 1000 ) ] #NEWLINE# debug_print ( '\nExpression:' , expr ) #NEWLINE# with TempdirBlitz ( ) : #NEWLINE# #INDENT# for size in all_sizes : #NEWLINE# #INDENT# arg_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for arg in arg_list : #NEWLINE# #INDENT# arg_dict [ arg ] = random . normal ( 0 , 1 , size ) . astype ( typ ) #NEWLINE# try : #NEWLINE# #INDENT# arg_dict [ arg ] . imag = arg_dict [ arg ] . real #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# debug_print ( 'Run:' , size , typ ) #NEWLINE# ( standard , compiled ) = self . generic_check ( expr , arg_dict , type , size ) #NEWLINE# try : #NEWLINE# #INDENT# speed_up = ( standard / compiled ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# speed_up = ( - 1.0 ) #NEWLINE# #UNINDENT# debug_print ( ( '1st run(numpy,compiled,speed up):  %3.4f, %3.4f, %3.4f' % ( standard , compiled , speed_up ) ) ) #NEWLINE# ( standard , compiled ) = self . generic_check ( expr , arg_dict , type , size ) #NEWLINE# try : #NEWLINE# #INDENT# speed_up = ( standard / compiled ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# speed_up = ( - 1.0 ) #NEWLINE# #UNINDENT# debug_print ( ( '2nd run(numpy,compiled,speed up):  %3.4f, %3.4f, %3.4f' % ( standard , compiled , speed_up ) ) )