#NEWLINE# @ staticmethod #NEWLINE# def _get_mode( mode_arg , i_var_count , d_var_count ) : #NEWLINE# #INDENT# '\n        Tries to return an appropriate mode class.\n        Intended to be called only by __new__.\n\n        mode_arg\n            Can be a string or a class. If it is a\n            PlotMode subclass, it is simply returned.\n            If it is a string, it can an alias for\n            a mode or an empty string. In the latter\n            case, we try to find a default mode for\n            the i_var_count and d_var_count.\n\n        i_var_count\n            The number of independent variables\n            needed to evaluate the d_vars.\n\n        d_var_count\n            The number of dependent variables;\n            usually the number of functions to\n            be evaluated in plotting.\n\n        For example, a Cartesian function y = f(x) has\n        one i_var (x) and one d_var (y). A parametric\n        form x,y,z = f(u,v), f(u,v), f(u,v) has two\n        two i_vars (u,v) and three d_vars (x,y,z).\n        ' #NEWLINE# try : #NEWLINE# #INDENT# m = None #NEWLINE# if issubclass ( mode_arg , PlotMode ) : #NEWLINE# #INDENT# m = mode_arg #NEWLINE# #UNINDENT# #UNINDENT# except TypeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# if m : #NEWLINE# #INDENT# if ( not m . _was_initialized ) : #NEWLINE# #INDENT# raise ValueError ( ( 'To use unregistered plot mode %s you must first call %s._init_mode().' % ( m . __name__ , m . __name__ ) ) ) #NEWLINE# #UNINDENT# if ( d_var_count != m . d_var_count ) : #NEWLINE# #INDENT# raise ValueError ( ( '%s can only plot functions with %i dependent variables.' % ( m . __name__ , m . d_var_count ) ) ) #NEWLINE# #UNINDENT# if ( i_var_count > m . i_var_count ) : #NEWLINE# #INDENT# raise ValueError ( ( '%s cannot plot functions with more than %i independent variables.' % ( m . __name__ , m . i_var_count ) ) ) #NEWLINE# #UNINDENT# return m #NEWLINE# #UNINDENT# if isinstance ( mode_arg , str ) : #NEWLINE# #INDENT# ( i , d ) = ( m , d_var_count ) #NEWLINE# if ( i > PlotMode . _i_var_max ) : #NEWLINE# #INDENT# raise ValueError ( var_count_error ( True , True ) ) #NEWLINE# #UNINDENT# if ( d > PlotMode . _d_var_max ) : #NEWLINE# #INDENT# raise ValueError ( var_count_error ( False , True ) ) #NEWLINE# #UNINDENT# if ( not mode_arg ) : #NEWLINE# #INDENT# return PlotMode . _get_default_mode ( i , d ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return PlotMode . _get_aliased_mode ( mode_arg , i , d ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'PlotMode argument must be a class or a string' )