@@ -209,10 +209,10 @@ def generate_canonical_names(docalias_qs):
209209 if stats_type == "authors" :
210210 stats_title = "Number of authors for each {}" .format (doc_label )
211211
212- bins = defaultdict (list )
212+ bins = defaultdict (set )
213213
214214 for name , canonical_name , author_count in generate_canonical_names (docalias_qs .values_list ("document" , "name" ).annotate (Count ("document__documentauthor" ))):
215- bins [author_count ].append (canonical_name )
215+ bins [author_count ].add (canonical_name )
216216
217217 series_data = []
218218 for author_count , names in sorted (bins .iteritems (), key = lambda t : t [0 ]):
@@ -225,10 +225,10 @@ def generate_canonical_names(docalias_qs):
225225 elif stats_type == "pages" :
226226 stats_title = "Number of pages for each {}" .format (doc_label )
227227
228- bins = defaultdict (list )
228+ bins = defaultdict (set )
229229
230230 for name , canonical_name , pages in generate_canonical_names (docalias_qs .values_list ("document" , "name" , "document__pages" )):
231- bins [pages ].append (canonical_name )
231+ bins [pages ].add (canonical_name )
232232
233233 series_data = []
234234 for pages , names in sorted (bins .iteritems (), key = lambda t : t [0 ]):
@@ -244,10 +244,10 @@ def generate_canonical_names(docalias_qs):
244244
245245 bin_size = 500
246246
247- bins = defaultdict (list )
247+ bins = defaultdict (set )
248248
249249 for name , canonical_name , words in generate_canonical_names (docalias_qs .values_list ("document" , "name" , "document__words" )):
250- bins [put_into_bin (words , bin_size )].append (canonical_name )
250+ bins [put_into_bin (words , bin_size )].add (canonical_name )
251251
252252 series_data = []
253253 for (value , words ), names in sorted (bins .iteritems (), key = lambda t : t [0 ][0 ]):
@@ -262,7 +262,7 @@ def generate_canonical_names(docalias_qs):
262262 elif stats_type == "format" :
263263 stats_title = "Submission formats for each {}" .format (doc_label )
264264
265- bins = defaultdict (list )
265+ bins = defaultdict (set )
266266
267267 # on new documents, we should have a Submission row with the file types
268268 submission_types = {}
@@ -275,7 +275,7 @@ def generate_canonical_names(docalias_qs):
275275 types = submission_types .get (doc_name )
276276 if types :
277277 for dot_ext in types .split ("," ):
278- bins [dot_ext .lstrip ("." ).upper ()].append (canonical_name )
278+ bins [dot_ext .lstrip ("." ).upper ()].add (canonical_name )
279279
280280 else :
281281
@@ -299,7 +299,7 @@ def generate_canonical_names(docalias_qs):
299299 canonical_name = doc_names_with_missing_types .get (basename )
300300
301301 if canonical_name :
302- bins [ext .upper ()].append (canonical_name )
302+ bins [ext .upper ()].add (canonical_name )
303303
304304 series_data = []
305305 for fmt , names in sorted (bins .iteritems (), key = lambda t : t [0 ]):
@@ -313,10 +313,10 @@ def generate_canonical_names(docalias_qs):
313313 elif stats_type == "formlang" :
314314 stats_title = "Formal languages used for each {}" .format (doc_label )
315315
316- bins = defaultdict (list )
316+ bins = defaultdict (set )
317317
318318 for name , canonical_name , formal_language_name in generate_canonical_names (docalias_qs .values_list ("document" , "name" , "document__formal_languages__name" )):
319- bins [formal_language_name ].append (canonical_name )
319+ bins [formal_language_name ].add (canonical_name )
320320
321321 series_data = []
322322 for formal_language , names in sorted (bins .iteritems (), key = lambda t : t [0 ]):
@@ -360,12 +360,12 @@ def generate_canonical_names(docalias_qs):
360360 if stats_type == "author/documents" :
361361 stats_title = "Number of {}s per author" .format (doc_label )
362362
363- bins = defaultdict (list )
363+ bins = defaultdict (set )
364364
365365 person_qs = Person .objects .filter (person_filters )
366366
367367 for name , document_count in person_qs .values_list ("name" ).annotate (Count ("documentauthor" )):
368- bins [document_count ].append (name )
368+ bins [document_count ].add (name )
369369
370370 total_persons = count_bins (bins )
371371
@@ -380,7 +380,7 @@ def generate_canonical_names(docalias_qs):
380380 elif stats_type == "author/affiliation" :
381381 stats_title = "Number of {} authors per affiliation" .format (doc_label )
382382
383- bins = defaultdict (list )
383+ bins = defaultdict (set )
384384
385385 person_qs = Person .objects .filter (person_filters )
386386
@@ -396,7 +396,7 @@ def generate_canonical_names(docalias_qs):
396396 aliases = get_aliased_affiliations (affiliation for _ , affiliation in name_affiliation_set )
397397
398398 for name , affiliation in name_affiliation_set :
399- bins [aliases .get (affiliation , affiliation )].append (name )
399+ bins [aliases .get (affiliation , affiliation )].add (name )
400400
401401 prune_unknown_bin_with_known (bins )
402402 total_persons = count_bins (bins )
@@ -419,7 +419,7 @@ def generate_canonical_names(docalias_qs):
419419 elif stats_type == "author/country" :
420420 stats_title = "Number of {} authors per country" .format (doc_label )
421421
422- bins = defaultdict (list )
422+ bins = defaultdict (set )
423423
424424 person_qs = Person .objects .filter (person_filters )
425425
@@ -440,11 +440,11 @@ def generate_canonical_names(docalias_qs):
440440
441441 for name , country in name_country_set :
442442 country_name = aliases .get (country , country )
443- bins [country_name ].append (name )
443+ bins [country_name ].add (name )
444444
445445 c = countries .get (country_name )
446446 if c and c .in_eu :
447- bins [eu_name ].append (name )
447+ bins [eu_name ].add (name )
448448
449449 prune_unknown_bin_with_known (bins )
450450 total_persons = count_bins (bins )
@@ -469,7 +469,7 @@ def generate_canonical_names(docalias_qs):
469469 elif stats_type == "author/continent" :
470470 stats_title = "Number of {} authors per continent" .format (doc_label )
471471
472- bins = defaultdict (list )
472+ bins = defaultdict (set )
473473
474474 person_qs = Person .objects .filter (person_filters )
475475
@@ -485,7 +485,7 @@ def generate_canonical_names(docalias_qs):
485485 for name , country in name_country_set :
486486 country_name = aliases .get (country , country )
487487 continent_name = country_to_continent .get (country_name , "" )
488- bins [continent_name ].append (name )
488+ bins [continent_name ].add (name )
489489
490490 prune_unknown_bin_with_known (bins )
491491 total_persons = count_bins (bins )
@@ -504,15 +504,15 @@ def generate_canonical_names(docalias_qs):
504504 elif stats_type == "author/citations" :
505505 stats_title = "Number of citations of {}s written by author" .format (doc_label )
506506
507- bins = defaultdict (list )
507+ bins = defaultdict (set )
508508
509509 cite_relationships = list (DocRelationshipName .objects .filter (slug__in = ['refnorm' , 'refinfo' , 'refunk' , 'refold' ]))
510510 person_filters &= Q (documentauthor__document__docalias__relateddocument__relationship__in = cite_relationships )
511511
512512 person_qs = Person .objects .filter (person_filters )
513513
514514 for name , citations in person_qs .values_list ("name" ).annotate (Count ("documentauthor__document__docalias__relateddocument" )):
515- bins [citations ].append (name )
515+ bins [citations ].add (name )
516516
517517 total_persons = count_bins (bins )
518518
@@ -527,7 +527,7 @@ def generate_canonical_names(docalias_qs):
527527 elif stats_type == "author/hindex" :
528528 stats_title = "h-index for {}s written by author" .format (doc_label )
529529
530- bins = defaultdict (list )
530+ bins = defaultdict (set )
531531
532532 cite_relationships = list (DocRelationshipName .objects .filter (slug__in = ['refnorm' , 'refinfo' , 'refunk' , 'refold' ]))
533533 person_filters &= Q (documentauthor__document__docalias__relateddocument__relationship__in = cite_relationships )
@@ -537,7 +537,7 @@ def generate_canonical_names(docalias_qs):
537537 values = person_qs .values_list ("name" , "documentauthor__document" ).annotate (Count ("documentauthor__document__docalias__relateddocument" ))
538538 for name , ts in itertools .groupby (values .order_by ("name" ), key = lambda t : t [0 ]):
539539 h_index = compute_hirsch_index ([citations for _ , document , citations in ts ])
540- bins [h_index ].append (name )
540+ bins [h_index ].add (name )
541541
542542 total_persons = count_bins (bins )
543543
0 commit comments