parameters: (A, B, opts)
return_statement: return res
docstring: compareResults - Generate a relation from diagnostics in run A to
      diagnostics in run B.
  
      The result is the relation as a list of triples (a, b) where
      each element {a,b} is None or a matching element from the respective run
docstring_summary: compareResults - Generate a relation from diagnostics in run A to
      diagnostics in run B.
docstring_tokens: compareResults - Generate a relation from diagnostics in run A to diagnostics in run B .
function: def compareResults(A, B, opts):
      """
      compareResults - Generate a relation from diagnostics in run A to
      diagnostics in run B.
  
      The result is the relation as a list of triples (a, b) where
      each element {a,b} is None or a matching element from the respective run
      """
  
      res = []
  
      # Map size_before -> size_after
      path_difference_data = []
  
      # Quickly eliminate equal elements.
      neqA = []
      neqB = []
      eltsA = list(A.diagnostics)
      eltsB = list(B.diagnostics)
      eltsA.sort(key=cmpAnalysisDiagnostic)
      eltsB.sort(key=cmpAnalysisDiagnostic)
      while eltsA and eltsB:
          a = eltsA.pop()
          b = eltsB.pop()
          if (a.getIssueIdentifier() == b.getIssueIdentifier()):
              if a.getPathLength() != b.getPathLength():
                  if opts.relative_path_histogram:
                      path_difference_data.append(
                          float(a.getPathLength()) / b.getPathLength())
                  elif opts.relative_log_path_histogram:
                      path_difference_data.append(
                          log(float(a.getPathLength()) / b.getPathLength()))
                  elif opts.absolute_path_histogram:
                      path_difference_data.append(
                          a.getPathLength() - b.getPathLength())
  
              res.append((a, b))
          elif a.getIssueIdentifier() > b.getIssueIdentifier():
              eltsB.append(b)
              neqA.append(a)
          else:
              eltsA.append(a)
              neqB.append(b)
      neqA.extend(eltsA)
      neqB.extend(eltsB)
  
      # FIXME: Add fuzzy matching. One simple and possible effective idea would
      # be to bin the diagnostics, print them in a normalized form (based solely
      # on the structure of the diagnostic), compute the diff, then use that as
      # the basis for matching. This has the nice property that we don't depend
      # in any way on the diagnostic format.
  
      for a in neqA:
          res.append((a, None))
      for b in neqB:
          res.append((None, b))
  
      if opts.relative_log_path_histogram or opts.relative_path_histogram or \
              opts.absolute_path_histogram:
          from matplotlib import pyplot
          pyplot.hist(path_difference_data, bins=100)
          pyplot.show()
  
      return res
function_tokens: def compareResults ( A , B , opts ) : res = [ ] # Map size_before -> size_after path_difference_data = [ ] # Quickly eliminate equal elements. neqA = [ ] neqB = [ ] eltsA = list ( A . diagnostics ) eltsB = list ( B . diagnostics ) eltsA . sort ( key = cmpAnalysisDiagnostic ) eltsB . sort ( key = cmpAnalysisDiagnostic ) while eltsA and eltsB : a = eltsA . pop ( ) b = eltsB . pop ( ) if ( a . getIssueIdentifier ( ) == b . getIssueIdentifier ( ) ) : if a . getPathLength ( ) != b . getPathLength ( ) : if opts . relative_path_histogram : path_difference_data . append ( float ( a . getPathLength ( ) ) / b . getPathLength ( ) ) elif opts . relative_log_path_histogram : path_difference_data . append ( log ( float ( a . getPathLength ( ) ) / b . getPathLength ( ) ) ) elif opts . absolute_path_histogram : path_difference_data . append ( a . getPathLength ( ) - b . getPathLength ( ) ) res . append ( ( a , b ) ) elif a . getIssueIdentifier ( ) > b . getIssueIdentifier ( ) : eltsB . append ( b ) neqA . append ( a ) else : eltsA . append ( a ) neqB . append ( b ) neqA . extend ( eltsA ) neqB . extend ( eltsB ) # FIXME: Add fuzzy matching. One simple and possible effective idea would # be to bin the diagnostics, print them in a normalized form (based solely # on the structure of the diagnostic), compute the diff, then use that as # the basis for matching. This has the nice property that we don't depend # in any way on the diagnostic format. for a in neqA : res . append ( ( a , None ) ) for b in neqB : res . append ( ( None , b ) ) if opts . relative_log_path_histogram or opts . relative_path_histogram or opts . absolute_path_histogram : from matplotlib import pyplot pyplot . hist ( path_difference_data , bins = 100 ) pyplot . show ( ) return res