Skip to content

Commit 7ce4bfa

Browse files
authored
Minor code and comment cleanup (GH-16315)
1 parent 87d6cd3 commit 7ce4bfa

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/statistics.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,9 @@ def mode(data):
555555
556556
"""
557557
data = iter(data)
558+
pairs = Counter(data).most_common(1)
558559
try:
559-
return Counter(data).most_common(1)[0][0]
560+
return pairs[0][0]
560561
except IndexError:
561562
raise StatisticsError('no mode for empty data') from None
562563

@@ -602,6 +603,7 @@ def multimode(data):
602603
# mean=0.300. Only the latter (which corresponds with R6) gives the
603604
# desired cut point with 30% of the population falling below that
604605
# value, making it comparable to a result from an inv_cdf() function.
606+
# The R6 exclusive method is also idempotent.
605607

606608
# For describing population data where the end points are known to
607609
# be included in the data, the R7 inclusive method is a reasonable

0 commit comments

Comments
 (0)