From: Luke Kenneth Casson Leighton Date: Sat, 9 Apr 2022 05:47:39 +0000 (+0100) Subject: whitespace cleanup: X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=be32ed3a3af9a2b224ea83c0cedcd006ddcacd8c;p=nmutil.git whitespace cleanup: * 80-char limit * {code} {semi-colon} {docstring} reduces line-count, increases clarity nothing can be done about URLs greater than 80 chars unfortunately --- diff --git a/src/nmutil/prefix_sum.py b/src/nmutil/prefix_sum.py index 34bfefa..f99a912 100644 --- a/src/nmutil/prefix_sum.py +++ b/src/nmutil/prefix_sum.py @@ -15,19 +15,15 @@ class Op: The operation is `items[self.out] = fn(items[self.lhs], items[self.rhs])`. The operation is not assumed to be commutative. """ - out: int - """the index of the item to output to""" - lhs: int - """the index of the item the left-hand-side input comes from""" - rhs: int - """the index of the item the right-hand-side input comes from""" - row: int - """the row in the prefix-sum diagram""" + out: int; """index of the item to output to""" + lhs: int; """index of the item the left-hand-side input comes from""" + rhs: int; """index of the item the right-hand-side input comes from""" + row: int; """row in the prefix-sum diagram""" def prefix_sum_ops(item_count, *, work_efficient=False): - """ Get the associative operations needed to compute a parallel prefix-sum of - `item_count` items. + """ Get the associative operations needed to compute a parallel prefix-sum + of `item_count` items. The operations aren't assumed to be commutative. @@ -150,7 +146,8 @@ def render_prefix_sum_diagram(item_count, *, work_efficient=False, ops_by_row[op.row].add(op) def blank_row(): - return [_Cell(slant=False, plus=False, tee=False) for _ in range(item_count)] + return [_Cell(slant=False, plus=False, tee=False) \ + for _ in range(item_count)] cells = [blank_row()] @@ -219,9 +216,10 @@ def render_prefix_sum_diagram(item_count, *, work_efficient=False, if __name__ == "__main__": - print("the non-work-efficient algorithm, matches the diagram in wikipedia:") - print("https://commons.wikimedia.org/wiki/File:Hillis-Steele_Prefix_Sum.svg") - print() + print("the non-work-efficient algorithm, matches the diagram in wikipedia:" + "\n" + "https://commons.wikimedia.org/wiki/File:Hillis-Steele_Prefix_Sum.svg" + "\n\n") print(render_prefix_sum_diagram(16, work_efficient=False)) print() print()