original_docstring: 
          this one is to make sure the functions are reordered
          correctly, should be ported from the original codebase
          
docstring: this one is to make sure the functions are reordered
  correctly, should be ported from the original codebase
docstring_tokens: this one is to make sure the functions are reordered correctly should be ported from the original codebase
code: def reorder_functions(self):
          """
          this one is to make sure the functions are reordered
          correctly, should be ported from the original codebase
          """
          # initialize dependency graph
          func_names = {}
          dep_dict = {}
          for fkey in self.functions:
              func = self.functions[fkey]
              # this finds the pure function name
              # with or without parans
              ma = re.search(r"(\W|^)(\w*)(\(*)(\w*)(\)*)(\W|$)", fkey)
              pure_name = ma.group(2)
              func_names[pure_name] = func.Id
              if "fRate" not in func.Id:
                  dep_dict[func.Id] = []
          # make dependency graph between funcs only
          func_order = []
          unparsed = []
          frates = []
          func_dict = {}
          # Let's replace and build dependency map
          for fkey in self.functions:
              func = self.functions[fkey]
              f = func.definition
              f = self.remove_sympy_symbols(f)
              try:
                  fs = sympy.sympify(f, locals=self.all_syms)
                  self.parsed_func[fkey] = fs
              except:
                  # Can't parse this func
                  if fkey.startswith("fRate"):
                      frates.append(fkey)
                  else:
                      unparsed.append(fkey)
                  continue
              func_dict[fkey] = fs
              # need to build a dependency graph to figure out what to
              # write first
              # We can skip this if it's a functionRate
              if "fRate" not in fkey:
                  list_of_deps = list(map(str, fs.atoms(sympy.Symbol)))
                  for dep in list_of_deps:
                      if dep in func_names:
                          dep_dict[fkey].append(func_names[dep])
              else:
                  frates.append(fkey)
          # Now reorder accordingly
          ordered_funcs = []
          # this ensures we write the independendent functions first
          stck = sorted(dep_dict.keys(), key=lambda x: len(dep_dict[x]))
          # FIXME: This algorithm works but likely inefficient
          while len(stck) > 0:
              k = stck.pop()
              deps = dep_dict[k]
              if len(deps) == 0:
                  if k not in ordered_funcs:
                      ordered_funcs.append(k)
              else:
                  stck.append(k)
                  for dep in deps:
                      if dep not in ordered_funcs:
                          stck.append(dep)
                      dep_dict[k].remove(dep)
          # print ordered functions and return
          ordered_funcs += frates
          self.function_order = ordered_funcs
code_tokens: def reorder_functions ( self ) : func_names = { } dep_dict = { } for fkey in self . functions : func = self . functions [ fkey ] ma = re . search ( r"(\W|^)(\w*)(\(*)(\w*)(\)*)(\W|$)" , fkey ) pure_name = ma . group ( 2 ) func_names [ pure_name ] = func . Id if "fRate" not in func . Id : dep_dict [ func . Id ] = [ ] func_order = [ ] unparsed = [ ] frates = [ ] func_dict = { } for fkey in self . functions : func = self . functions [ fkey ] f = func . definition f = self . remove_sympy_symbols ( f ) try : fs = sympy . sympify ( f , locals = self . all_syms ) self . parsed_func [ fkey ] = fs except : if fkey . startswith ( "fRate" ) : frates . append ( fkey ) else : unparsed . append ( fkey ) continue func_dict [ fkey ] = fs if "fRate" not in fkey : list_of_deps = list ( map ( str , fs . atoms ( sympy . Symbol ) ) ) for dep in list_of_deps : if dep in func_names : dep_dict [ fkey ] . append ( func_names [ dep ] ) else : frates . append ( fkey ) ordered_funcs = [ ] stck = sorted ( dep_dict . keys ( ) , key = lambda x : len ( dep_dict [ x ] ) ) while len ( stck ) > 0 : k = stck . pop ( ) deps = dep_dict [ k ] if len ( deps ) == 0 : if k not in ordered_funcs : ordered_funcs . append ( k ) else : stck . append ( k ) for dep in deps : if dep not in ordered_funcs : stck . append ( dep ) dep_dict [ k ] . remove ( dep ) ordered_funcs += frates self . function_order = ordered_funcs
short_docstring: this one is to make sure the functions are reordered
  correctly, should be ported from the original codebase
short_docstring_tokens: this one is to make sure the functions are reordered correctly should be ported from the original codebase
comment: """
          this one is to make sure the functions are reordered
          correctly, should be ported from the original codebase
          """$SEP$# initialize dependency graph$SEP$# this finds the pure function name$SEP$# with or without parans$SEP$# make dependency graph between funcs only$SEP$# Let's replace and build dependency map$SEP$# Can't parse this func$SEP$# need to build a dependency graph to figure out what to$SEP$# write first$SEP$# We can skip this if it's a functionRate$SEP$# Now reorder accordingly$SEP$# this ensures we write the independendent functions first$SEP$# FIXME: This algorithm works but likely inefficient$SEP$# print ordered functions and return