66msgstr ""
77"Project-Id-Version : Python 3.14\n "
88"Report-Msgid-Bugs-To : \n "
9- "POT-Creation-Date : 2026-04-09 00:20 +0000\n "
9+ "POT-Creation-Date : 2026-04-25 00:26 +0000\n "
1010"PO-Revision-Date : 2024-08-16 15:01+0800\n "
1111"Last-Translator : Adrian Liaw <adrianliaw2000@gmail.com>\n "
1212"Language-Team : Chinese - TAIWAN (https://github.com/python/python-docs-zh- "
@@ -1808,13 +1808,15 @@ msgstr ""
18081808"term:`產生器 <generator>`,則能保持高速度。"
18091809
18101810#: ../../library/itertools.rst:831
1811+ #, fuzzy
18111812msgid ""
18121813"from itertools import (accumulate, batched, chain, combinations, compress,\n"
18131814" count, cycle, filterfalse, groupby, islice, permutations, product,\n"
18141815" repeat, starmap, tee, zip_longest)\n"
18151816"from collections import Counter, deque\n"
18161817"from contextlib import suppress\n"
18171818"from functools import reduce\n"
1819+ "from heapq import heappush, heappushpop, heappush_max, heappushpop_max\n"
18181820"from math import comb, isqrt, prod, sumprod\n"
18191821"from operator import getitem, is_not, itemgetter, mul, neg, truediv\n"
18201822"\n"
@@ -1830,11 +1832,6 @@ msgid ""
18301832" # prepend(1, [2, 3, 4]) → 1 2 3 4\n"
18311833" return chain([value], iterable)\n"
18321834"\n"
1833- "def running_mean(iterable):\n"
1834- " \" Yield the average of all values seen so far.\" \n"
1835- " # running_mean([8.5, 9.5, 7.5, 6.5]) → 8.5 9.0 8.5 8.0\n"
1836- " return map(truediv, accumulate(iterable), count(1))\n"
1837- "\n"
18381835"def repeatfunc(function, times=None, *args):\n"
18391836" \" Repeat calls to a function with specified arguments.\" \n"
18401837" if times is None:\n"
@@ -2134,7 +2131,50 @@ msgid ""
21342131" # totient(12) → 4 because len([1, 5, 7, 11]) == 4\n"
21352132" for prime in set(factor(n)):\n"
21362133" n -= n // prime\n"
2137- " return n"
2134+ " return n\n"
2135+ "\n"
2136+ "\n"
2137+ "# ==== Running statistics ====\n"
2138+ "\n"
2139+ "def running_mean(iterable):\n"
2140+ " \" Average of values seen so far.\" \n"
2141+ " # running_mean([37, 33, 38, 28]) → 37 35 36 34\n"
2142+ " return map(truediv, accumulate(iterable), count(1))\n"
2143+ "\n"
2144+ "def running_min(iterable):\n"
2145+ " \" Smallest of values seen so far.\" \n"
2146+ " # running_min([37, 33, 38, 28]) → 37 33 33 28\n"
2147+ " return accumulate(iterable, func=min)\n"
2148+ "\n"
2149+ "def running_max(iterable):\n"
2150+ " \" Largest of values seen so far.\" \n"
2151+ " # running_max([37, 33, 38, 28]) → 37 37 38 38\n"
2152+ " return accumulate(iterable, func=max)\n"
2153+ "\n"
2154+ "def running_median(iterable):\n"
2155+ " \" Median of values seen so far.\" \n"
2156+ " # running_median([37, 33, 38, 28]) → 37 35 37 35\n"
2157+ " read = iter(iterable).__next__\n"
2158+ " lo = [] # max-heap\n"
2159+ " hi = [] # min-heap the same size as or one smaller than lo\n"
2160+ " with suppress(StopIteration):\n"
2161+ " while True:\n"
2162+ " heappush_max(lo, heappushpop(hi, read()))\n"
2163+ " yield lo[0]\n"
2164+ " heappush(hi, heappushpop_max(lo, read()))\n"
2165+ " yield (lo[0] + hi[0]) / 2\n"
2166+ "\n"
2167+ "def running_statistics(iterable):\n"
2168+ " \" Aggregate statistics for values seen so far.\" \n"
2169+ " # Generate tuples: (size, minimum, median, maximum, mean)\n"
2170+ " t0, t1, t2, t3 = tee(iterable, 4)\n"
2171+ " return zip(\n"
2172+ " count(1),\n"
2173+ " running_min(t0),\n"
2174+ " running_median(t1),\n"
2175+ " running_max(t2),\n"
2176+ " running_mean(t3),\n"
2177+ " )"
21382178msgstr ""
21392179"from itertools import (accumulate, batched, chain, combinations, compress,\n"
21402180" count, cycle, filterfalse, groupby, islice, permutations, product,\n"
0 commit comments