nodes: 0, module; 1, function_definition; 2, function_name:letter_scales; 3, parameters; 4, block; 5, identifier:counts; 6, expression_statement; 7, try_statement; 8, expression_statement; 9, expression_statement; 10, return_statement; 11, comment:"""Convert letter counts to frequencies, sorted increasing."""; 12, block; 13, except_clause; 14, assignment; 15, call; 16, identifier:freqs; 17, expression_statement; 18, identifier:ZeroDivisionError; 19, comment:# This logo is all gaps, nothing can be done; 20, block; 21, identifier:freqs; 22, list_comprehension; 23, attribute; 24, argument_list; 25, assignment; 26, return_statement; 27, tuple; 28, for_in_clause; 29, if_clause; 30, identifier:freqs; 31, identifier:sort; 32, keyword_argument; 33, identifier:scale; 34, binary_operator:1.0 / sum(counts.values()); 35, list; 36, identifier:aa; 37, binary_operator:cnt*scale; 38, pattern_list; 39, call; 40, identifier:cnt; 41, identifier:key; 42, lambda; 43, float:1.0; 44, call; 45, identifier:cnt; 46, identifier:scale; 47, identifier:aa; 48, identifier:cnt; 49, attribute; 50, argument_list; 51, lambda_parameters; 52, subscript; 53, identifier:sum; 54, argument_list; 55, identifier:counts; 56, identifier:iteritems; 57, identifier:pair; 58, identifier:pair; 59, integer:1; 60, call; 61, attribute; 62, argument_list; 63, identifier:counts; 64, identifier:values
code: def letter_scales(counts):
      """Convert letter counts to frequencies, sorted increasing.""" 
      try:
          scale = 1.0 / sum(counts.values())
      except ZeroDivisionError:
          # This logo is all gaps, nothing can be done
          return []
      freqs = [(aa, cnt*scale) for aa, cnt in counts.iteritems() if cnt]
      freqs.sort(key=lambda pair: pair[1])
      return freqs