#NEWLINE# def _import( module , reload = 'False' ) : #NEWLINE# #INDENT# '\n    Creates a global translation dictionary for module.\n\n    The argument module has to be one of the following strings: "math",\n    "mpmath", "numpy", "sympy".\n    These dictionaries map names of python functions to their equivalent in\n    other modules.\n    ' #NEWLINE# from sympy.external import import_module #NEWLINE# try : #NEWLINE# #INDENT# ( namespace , namespace_default , translations , import_commands ) = MODULES [ module ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# raise NameError ( ( "'%s' module can't be used for lambdification" % module ) ) #NEWLINE# #UNINDENT# if ( namespace != namespace_default ) : #NEWLINE# #INDENT# if reload : #NEWLINE# #INDENT# namespace . clear ( ) #NEWLINE# namespace . update ( namespace_default ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# #UNINDENT# for import_command in import_commands : #NEWLINE# #INDENT# if import_command . startswith ( 'import_module' ) : #NEWLINE# #INDENT# module = eval ( import_command ) #NEWLINE# if ( namespace is not None ) : #NEWLINE# #INDENT# namespace . update ( module . __dict__ ) #NEWLINE# continue #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# exec_ ( import_command , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , namespace ) #NEWLINE# continue #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# raise ImportError ( ( "can't import '%s' with '%s' command" % ( module , import_command ) ) ) #NEWLINE# #UNINDENT# for ( sympyname , translation ) in translations . items ( ) : #NEWLINE# #INDENT# namespace [ sympyname ] = namespace [ translation ] #NEWLINE# #UNINDENT# if ( 'Abs' not in namespace ) : #NEWLINE# #INDENT# namespace [ 'Abs' ] = abs