Skip to content

Commit

Permalink
Add default arg to max
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Powers committed Apr 23, 2024
1 parent 80d854a commit 4ade099
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions chameleon/research_impacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def extension_information():
allocation_counts = _allocation_counts(
Project.objects.filter(allocations__status__in=allocation_statuses)
)
max_allocations = max(allocation_counts)
max_allocations = max(allocation_counts, default=0)
med_allocations = statistics.median(allocation_counts)
percentage_extended = (
len(list(ac for ac in allocation_counts if ac > 1))
Expand All @@ -113,7 +113,7 @@ def extension_information():
allocations__status__in=allocation_statuses, tag=computing_education_tag
)
)
edu_max_allocations = max(education_allocation_counts)
edu_max_allocations = max(education_allocation_counts, default=0)
edu_med_allocations = statistics.median(education_allocation_counts)
edu_percentage_extended = (
len(list(ac for ac in education_allocation_counts if ac > 1))
Expand Down Expand Up @@ -291,7 +291,7 @@ def publication_information(start_year, end_year):
def citation_report():
publications = []
for p in Publication.objects.all():
publications.append((p, max(s.citation_count for s in p.sources.all())))
publications.append((p, max((s.citation_count for s in p.sources.all()), default=0)))
total = sum(p[1] for p in publications)
gt100_unsorted = [
(f"{p[0].project} - {p[0].title}", p[1]) for p in publications if p[1] >= 100
Expand Down

0 comments on commit 4ade099

Please sign in to comment.