parameters: (first_list, second_list,offset,max_difference)
return_statement: return matches
docstring: Associate two dictionaries of (stamp,data). As the time stamps never match exactly, we aim 
      to find the closest match for every input tuple.
      
      Input:
      first_list -- first dictionary of (stamp,data) tuples
      second_list -- second dictionary of (stamp,data) tuples
      offset -- time offset between both dictionaries (e.g., to model the delay between the sensors)
      max_difference -- search radius for candidate generation
  
      Output:
      matches -- list of matched tuples ((stamp1,data1),(stamp2,data2))
docstring_summary: Associate two dictionaries of (stamp,data). As the time stamps never match exactly, we aim 
      to find the closest match for every input tuple.
      
      Input:
      first_list -- first dictionary of (stamp,data) tuples
      second_list -- second dictionary of (stamp,data) tuples
      offset -- time offset between both dictionaries (e.g., to model the delay between the sensors)
      max_difference -- search radius for candidate generation
docstring_tokens: Associate two dictionaries of ( stamp data ) . As the time stamps never match exactly we aim to find the closest match for every input tuple . Input : first_list -- first dictionary of ( stamp data ) tuples second_list -- second dictionary of ( stamp data ) tuples offset -- time offset between both dictionaries ( e . g . to model the delay between the sensors ) max_difference -- search radius for candidate generation
function: def associate(first_list, second_list,offset,max_difference):
      """
      Associate two dictionaries of (stamp,data). As the time stamps never match exactly, we aim 
      to find the closest match for every input tuple.
      
      Input:
      first_list -- first dictionary of (stamp,data) tuples
      second_list -- second dictionary of (stamp,data) tuples
      offset -- time offset between both dictionaries (e.g., to model the delay between the sensors)
      max_difference -- search radius for candidate generation
  
      Output:
      matches -- list of matched tuples ((stamp1,data1),(stamp2,data2))
      
      """
      first_keys = first_list.keys()
      second_keys = second_list.keys()
      potential_matches = [(abs(a - (b + offset)), a, b) 
                           for a in first_keys 
                           for b in second_keys 
                           if abs(a - (b + offset)) < max_difference]
      potential_matches.sort()
      matches = []
      for diff, a, b in potential_matches:
          if a in first_keys and b in second_keys:
              first_keys.remove(a)
              second_keys.remove(b)
              matches.append((a, b))
      
      matches.sort()
      return matches
function_tokens: def associate ( first_list , second_list , offset , max_difference ) : first_keys = first_list . keys ( ) second_keys = second_list . keys ( ) potential_matches = [ ( abs ( a - ( b + offset ) ) , a , b ) for a in first_keys for b in second_keys if abs ( a - ( b + offset ) ) < max_difference ] potential_matches . sort ( ) matches = [ ] for diff , a , b in potential_matches : if a in first_keys and b in second_keys : first_keys . remove ( a ) second_keys . remove ( b ) matches . append ( ( a , b ) ) matches . sort ( ) return matches