mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Some reformatting (suggested by Black) and minor factoring. (GH-20865)
This commit is contained in:
parent
d71ab4f738
commit
5aad027db9
1 changed files with 29 additions and 31 deletions
|
@ -554,8 +554,7 @@ def mode(data):
|
|||
If *data* is empty, ``mode``, raises StatisticsError.
|
||||
|
||||
"""
|
||||
data = iter(data)
|
||||
pairs = Counter(data).most_common(1)
|
||||
pairs = Counter(iter(data)).most_common(1)
|
||||
try:
|
||||
return pairs[0][0]
|
||||
except IndexError:
|
||||
|
@ -597,7 +596,7 @@ def multimode(data):
|
|||
# For sample data where there is a positive probability for values
|
||||
# beyond the range of the data, the R6 exclusive method is a
|
||||
# reasonable choice. Consider a random sample of nine values from a
|
||||
# population with a uniform distribution from 0.0 to 100.0. The
|
||||
# population with a uniform distribution from 0.0 to 1.0. The
|
||||
# distribution of the third ranked sample point is described by
|
||||
# betavariate(alpha=3, beta=7) which has mode=0.250, median=0.286, and
|
||||
# mean=0.300. Only the latter (which corresponds with R6) gives the
|
||||
|
@ -643,8 +642,7 @@ def quantiles(data, *, n=4, method='exclusive'):
|
|||
m = ld - 1
|
||||
result = []
|
||||
for i in range(1, n):
|
||||
j = i * m // n
|
||||
delta = i*m - j*n
|
||||
j, delta = divmod(i * m, n)
|
||||
interpolated = (data[j] * (n - delta) + data[j + 1] * delta) / n
|
||||
result.append(interpolated)
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue