8000 Neaten up the docstring for _rank(). · python/cpython@873e240 · GitHub
[go: up one dir, main page]

Skip to content

Commit 873e240

Browse files
committed
Neaten up the docstring for _rank().
1 parent 222699e commit 873e240

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Lib/statistics.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -358,24 +358,24 @@ def _fail_neg(values, errmsg='negative value'):
358358
def _rank(data, /, *, key=None, reverse=False, ties='average') -> list[float]:
359359
"""Rank order a dataset. The lowest value has rank 1.
360360
361-
Ties are averaged so that equal values receive the same rank.
361+
Ties are averaged so that equal values receive the same rank:
362362
363-
>>> data = [31, 56, 31, 25, 75, 18]
364-
>>> _rank(data)
365-
[3.5, 5.0, 3.5, 2.0, 6.0, 1.0]
363+
>>> data = [31, 56, 31, 25, 75, 18]
364+
>>> _rank(data)
365+
[3.5, 5.0, 3.5, 2.0, 6.0, 1.0]
366366
367-
The operation is idempotent.
367+
The operation is idempotent:
368368
369-
>>> _rank([3.5, 5.0, 3.5, 2.0, 6.0, 1.0])
370-
[3.5, 5.0, 3.5, 2.0, 6.0, 1.0]
369+
>>> _rank([3.5, 5.0, 3.5, 2.0, 6.0, 1.0])
370+
[3.5, 5.0, 3.5, 2.0, 6.0, 1.0]
371371
372372
It is possible to rank the data in reverse order so that
373373
the highest value has rank 1. Also, a key-function can
374374
extract the field to be ranked:
375375
376-
>>> goals = [('eagles', 45), ('bears', 48), ('lions', 44)]
377-
>>> _rank(goals, key=itemgetter(1), reverse=True)
378-
[2.0, 1.0, 3.0]
376+
>>> goals = [('eagles', 45), ('bears', 48), ('lions', 44)]
377+
>>> _rank(goals, key=itemgetter(1), reverse=True)
378+
[2.0, 1.0, 3.0]
379379
380380
"""
381381
# If this function becomes public at some point, more thought

0 commit comments

Comments
 (0)
0