@@ -1150,22 +1150,22 @@ and :term:`generators <generator>` which incur interpreter overhead.
11501150
11511151 def running_mean(iterable):
11521152 "Average of values seen so far."
1153- # running_mean([37, 33, 38, 28]) -> 37 35 36 34
1153+ # running_mean([37, 33, 38, 28]) → 37 35 36 34
11541154 return map(truediv, accumulate(iterable), count(1))
11551155
11561156 def running_min(iterable):
11571157 "Smallest of values seen so far."
1158- # running_min([37, 33, 38, 28]) -> 37 33 33 28
1158+ # running_min([37, 33, 38, 28]) → 37 33 33 28
11591159 return accumulate(iterable, func=min)
11601160
11611161 def running_max(iterable):
11621162 "Largest of values seen so far."
1163- # running_max([37, 33, 38, 28]) -> 37 37 38 38
1163+ # running_max([37, 33, 38, 28]) → 37 37 38 38
11641164 return accumulate(iterable, func=max)
11651165
11661166 def running_median(iterable):
11671167 "Median of values seen so far."
1168- # running_median([37, 33, 38, 28]) -> 37 35 37 35
1168+ # running_median([37, 33, 38, 28]) → 37 35 37 35
11691169 read = iter(iterable).__next__
11701170 lo = [] # max-heap
11711171 hi = [] # min-heap the same size as or one smaller than lo
@@ -1265,10 +1265,6 @@ and :term:`generators <generator>` which incur interpreter overhead.
12651265 [(0, 'a'), (1, 'b'), (2, 'c')]
12661266
12671267
1268- >>> list (running_mean([8.5 , 9.5 , 7.5 , 6.5 ]))
1269- [8.5, 9.0, 8.5, 8.0]
1270-
1271-
12721268 >>> for _ in loops(5 ):
12731269 ... print (' hi' )
12741270 ...
@@ -1828,6 +1824,28 @@ and :term:`generators <generator>` which incur interpreter overhead.
18281824 True
18291825
18301826
1827+ >>> list (running_mean([8.5 , 9.5 , 7.5 , 6.5 ]))
1828+ [8.5, 9.0, 8.5, 8.0]
1829+ >>> list (running_mean([37 , 33 , 38 , 28 ]))
1830+ [37.0, 35.0, 36.0, 34.0]
1831+
1832+
1833+ >>> list (running_min([37 , 33 , 38 , 28 ]))
1834+ [37, 33, 33, 28]
1835+
1836+
1837+ >>> list (running_max([37 , 33 , 38 , 28 ]))
1838+ [37, 37, 38, 38]
1839+
1840+
1841+ >>> list (running_median([37 , 33 , 38 , 28 ]))
1842+ [37, 35.0, 37, 35.0]
1843+
1844+
1845+ >>> list (running_statistics([37 , 33 , 38 , 28 ]))
1846+ [(1, 37, 37, 37, 37.0), (2, 33, 35.0, 37, 35.0), (3, 33, 37, 38, 36.0), (4, 28, 35.0, 38, 34.0)]
1847+
1848+
18311849.. testcode ::
18321850 :hide:
18331851
0 commit comments