@@ -844,8 +844,8 @@ and :term:`generators <generator>` which incur interpreter overhead.
844844 from collections import Counter, deque
845845 from contextlib import suppress
846846 from functools import reduce
847- from math import comb, prod, sumprod, isqrt
848- from operator import is_not, itemgetter, getitem , mul, neg
847+ from math import comb, isqrt, prod, sumprod
848+ from operator import getitem, is_not, itemgetter , mul, neg
849849
850850 # ==== Basic one liners ====
851851
@@ -904,16 +904,16 @@ and :term:`generators <generator>` which incur interpreter overhead.
904904
905905 def first_true(iterable, default=False, predicate=None):
906906 "Returns the first true value or the *default * if there is no true value."
907- # first_true([a,b, c], x) → a or b or c or x
908- # first_true([a,b], x, f) → a if f(a) else b if f(b) else x
907+ # first_true([a, b, c], x) → a or b or c or x
908+ # first_true([a, b], x, f) → a if f(a) else b if f(b) else x
909909 return next(filter(predicate, iterable), default)
910910
911911 def all_equal(iterable, key=None):
912912 "Returns True if all the elements are equal to each other."
913913 # all_equal('4٤௪౪໔', key=int) → True
914914 return len(take(2, groupby(iterable, key))) <= 1
915915
916- # ==== Data streams ====
916+ # ==== Data pipelines ====
917917
918918 def unique_justseen(iterable, key=None):
919919 "Yield unique elements, preserving order. Remember only the element just seen."
@@ -947,7 +947,7 @@ and :term:`generators <generator>` which incur interpreter overhead.
947947
948948 def sliding_window(iterable, n):
949949 "Collect data into overlapping fixed-length chunks or blocks."
950- # sliding_window('ABCDEFG', 4 ) → ABCD BCDE CDEF DEFG
950+ # sliding_window('ABCDEFG', 3 ) → ABC BCD CDE DEF EFG
951951 iterator = iter(iterable)
952952 window = deque(islice(iterator, n - 1), maxlen=n)
953953 for x in iterator:
@@ -956,7 +956,7 @@ and :term:`generators <generator>` which incur interpreter overhead.
956956
957957 def grouper(iterable, n, *, incomplete='fill', fillvalue=None):
958958 "Collect data into non-overlapping fixed-length chunks or blocks."
959- # grouper('ABCDEFG', 3, fillvalue='x') → ABC DEF Gxx
959+ # grouper('ABCDEFG', 3, fillvalue='x') → ABC DEF Gxx
960960 # grouper('ABCDEFG', 3, incomplete='strict') → ABC DEF ValueError
961961 # grouper('ABCDEFG', 3, incomplete='ignore') → ABC DEF
962962 iterators = [iter(iterable)] * n
@@ -1044,7 +1044,7 @@ and :term:`generators <generator>` which incur interpreter overhead.
10441044
10451045 def reshape(matrix, columns):
10461046 "Reshape a 2-D matrix to have a given number of columns."
1047- # reshape([(0, 1), (2, 3), (4, 5)], 3) → (0, 1, 2), (3, 4, 5)
1047+ # reshape([(0, 1), (2, 3), (4, 5)], 3) → (0, 1, 2) (3, 4, 5)
10481048 return batched(chain.from_iterable(matrix), columns, strict=True)
10491049
10501050 def transpose(matrix):
@@ -1054,10 +1054,12 @@ and :term:`generators <generator>` which incur interpreter overhead.
10541054
10551055 def matmul(m1, m2):
10561056 "Multiply two matrices."
1057- # matmul([(7, 5), (3, 5)], [(2, 5), (7, 9)]) → (49, 80), (41, 60)
1057+ # matmul([(7, 5), (3, 5)], [(2, 5), (7, 9)]) → (49, 80) (41, 60)
10581058 n = len(m2[0])
10591059 return batched(starmap(sumprod, product(m1, transpose(m2))), n)
10601060
1061+ # ==== Polynomial arithmetic ====
1062+
10611063 def convolve(signal, kernel):
10621064 """Discrete linear convolution of two iterables.
10631065 Equivalent to polynomial multiplication.
@@ -1079,8 +1081,6 @@ and :term:`generators <generator>` which incur interpreter overhead.
10791081 windowed_signal = sliding_window(padded_signal, n)
10801082 return map(sumprod, repeat(kernel), windowed_signal)
10811083
1082- # ==== Polynomial arithmetic ====
1083-
10841084 def polynomial_from_roots(roots):
10851085 """Compute a polynomial's coefficients from its roots.
10861086
0 commit comments