def _imp_namespace(expr, namespace=None):
 from sympy.core.function import FunctionClass
 if (namespace is None):
  namespace = {}
 if is_sequence(expr):
  for arg in expr:
   _imp_namespace(arg, namespace)
  return namespace
 elif isinstance(expr, dict):
  for (key, val) in expr.items():
   _imp_namespace(key, namespace)
   _imp_namespace(val, namespace)
  return namespace
 func = getattr(expr, 'func', None)
 if isinstance(func, FunctionClass):
  imp = getattr(func, '_imp_', None)
  if (imp is not None):
   name = expr.func.__name__
   if ((name in namespace) and (namespace[name] != imp)):
    raise ValueError(('We found more than one implementation with name "%s"' % name))
   namespace[name] = imp
 if hasattr(expr, 'args'):
  for arg in expr.args:
   _imp_namespace(arg, namespace)
 return namespace

def _imp_namespace ( expr , namespace = None ) : from sympy . core . function import FunctionClass if ( namespace is None ) : namespace = { } if is_sequence ( expr ) : for arg in expr : _imp_namespace ( arg , namespace ) return namespace elif isinstance ( expr , dict ) : for ( key , val ) in expr . items ( ) : _imp_namespace ( key , namespace ) _imp_namespace ( val , namespace ) return namespace func = getattr ( expr , 'func' , None ) if isinstance ( func , FunctionClass ) : imp = getattr ( func , '_imp_' , None ) if ( imp is not None ) : name = expr . func . __name__ if ( ( name in namespace ) and ( namespace [ name ] != imp ) ) : raise ValueError ( ( 'We found more than one implementation with name "%s"' % name ) ) namespace [ name ] = imp if hasattr ( expr , 'args' ) : for arg in expr . args : _imp_namespace ( arg , namespace ) return namespace
return namespace dict with function implementations we need to search for functions in anything that can be thrown at us - that is - anything that could be passed as expr .