parameters: (events)
return_statement: return events, is_terminal, direction
docstring: Standardize event functions and extract is_terminal and direction.
docstring_summary: Standardize event functions and extract is_terminal and direction.
docstring_tokens: Standardize event functions and extract is_terminal and direction .
function: def prepare_events(events):
      """Standardize event functions and extract is_terminal and direction."""
      if callable(events):
          events = (events,)
  
      if events is not None:
          is_terminal = np.empty(len(events), dtype=bool)
          direction = np.empty(len(events))
          for i, event in enumerate(events):
              try:
                  is_terminal[i] = event.terminal
              except AttributeError:
                  is_terminal[i] = False
  
              try:
                  direction[i] = event.direction
              except AttributeError:
                  direction[i] = 0
      else:
          is_terminal = None
          direction = None
  
      return events, is_terminal, direction
function_tokens: def prepare_events ( events ) : if callable ( events ) : events = ( events , ) if events is not None : is_terminal = np . empty ( len ( events ) , dtype = bool ) direction = np . empty ( len ( events ) ) for i , event in enumerate ( events ) : try : is_terminal [ i ] = event . terminal except AttributeError : is_terminal [ i ] = False try : direction [ i ] = event . direction except AttributeError : direction [ i ] = 0 else : is_terminal = None direction = None return events , is_terminal , direction