From 574d3b43c54546bdfb58addc2dadb2fcba97c33b Mon Sep 17 00:00:00 2001 From: Kaushik Kulkarni Date: Thu, 14 May 2020 23:12:05 -0500 Subject: [PATCH] pass flake8 CI --- loopy/cli.py | 8 ++++---- loopy/codegen/control.py | 10 +++++----- loopy/codegen/instruction.py | 2 +- loopy/frontend/fortran/__init__.py | 16 ++++++++-------- loopy/kernel/tools.py | 6 +++--- loopy/preprocess.py | 4 ++-- loopy/symbolic.py | 3 +-- loopy/tools.py | 6 +++--- loopy/transform/iname.py | 4 ++-- 9 files changed, 29 insertions(+), 30 deletions(-) diff --git a/loopy/cli.py b/loopy/cli.py index a92922b18..cdc24800b 100644 --- a/loopy/cli.py +++ b/loopy/cli.py @@ -39,13 +39,13 @@ def defines_to_python_code(defines_str): import re define_re = re.compile(r"^\#define\s+([a-zA-Z0-9_]+)\s+(.*)$") result = [] - for l in defines_str.split("\n"): - if not l.strip(): + for line in defines_str.split("\n"): + if not line.strip(): continue - match = define_re.match(l) + match = define_re.match(line) if match is None: - raise RuntimeError("#define not understood: '%s'" % l) + raise RuntimeError("#define not understood: '%s'" % line) result.append( "%s = %s" % (match.group(1), to_python_literal(match.group(2)))) diff --git a/loopy/codegen/control.py b/loopy/codegen/control.py index e9de52eb6..7319b16ac 100644 --- a/loopy/codegen/control.py +++ b/loopy/codegen/control.py @@ -197,14 +197,14 @@ def get_required_predicates(kernel, sched_index): return result -def group_by(l, key, merge): - if not l: - return l +def group_by(entry, key, merge): + if not entry: + return entry result = [] - previous = l[0] + previous = entry[0] - for item in l[1:]: + for item in entry[1:]: if key(previous) == key(item): previous = merge(previous, item) diff --git a/loopy/codegen/instruction.py b/loopy/codegen/instruction.py index 5e0747246..c0ca875c0 100644 --- a/loopy/codegen/instruction.py +++ b/loopy/codegen/instruction.py @@ -274,7 +274,7 @@ def generate_c_instruction_code(codegen_state, insn): if body: body.append(Line()) - body.extend(Line(l) for l in insn.code.split("\n")) + body.extend(Line(line) for line in insn.code.split("\n")) return Block(body) diff --git a/loopy/frontend/fortran/__init__.py b/loopy/frontend/fortran/__init__.py index 05b0a9205..40202d4da 100644 --- a/loopy/frontend/fortran/__init__.py +++ b/loopy/frontend/fortran/__init__.py @@ -86,17 +86,17 @@ def _extract_loopy_lines(source): loopy_lines = [] in_loopy_code = False - for l in lines: - comment_match = comment_re.match(l) + for line in lines: + comment_match = comment_re.match(line) if comment_match is None: if in_loopy_code: raise LoopyError("non-comment source line in loopy block") - remaining_lines.append(l) + remaining_lines.append(line) # Preserves line numbers in loopy code, for debuggability - loopy_lines.append("# "+l) + loopy_lines.append("# "+line) continue cmt = comment_match.group(1) @@ -108,7 +108,7 @@ def _extract_loopy_lines(source): in_loopy_code = True # Preserves line numbers in loopy code, for debuggability - loopy_lines.append("# "+l) + loopy_lines.append("# "+line) elif cmt_stripped == "$loopy end": if not in_loopy_code: @@ -116,16 +116,16 @@ def _extract_loopy_lines(source): in_loopy_code = False # Preserves line numbers in loopy code, for debuggability - loopy_lines.append("# "+l) + loopy_lines.append("# "+line) elif in_loopy_code: loopy_lines.append(cmt) else: - remaining_lines.append(l) + remaining_lines.append(line) # Preserves line numbers in loopy code, for debuggability - loopy_lines.append("# "+l) + loopy_lines.append("# "+line) return "\n".join(remaining_lines), "\n".join(loopy_lines) diff --git a/loopy/kernel/tools.py b/loopy/kernel/tools.py index 9e54bc25d..ac1e00bae 100644 --- a/loopy/kernel/tools.py +++ b/loopy/kernel/tools.py @@ -1380,7 +1380,7 @@ def draw_dependencies_as_unicode_arrows( .replace(style.RESET_ALL, "")) return len(s) - def truncate_without_color_escapes(s, l): + def truncate_without_color_escapes(s, length): # FIXME: This is a bit dumb--it removes color escapes when truncation # is needed. @@ -1388,7 +1388,7 @@ def draw_dependencies_as_unicode_arrows( .replace(fore.RED, "") .replace(style.RESET_ALL, "")) - return s[:l] + u"…" + return s[:length] + u"…" def conform_to_uniform_length(s): len_s = len_without_color_escapes(s) @@ -1510,7 +1510,7 @@ def stringify_instruction_list(kernel): ", ".join("%s=%s" % (name, expr) for name, expr in insn.iname_exprs)) - trailing = [l for l in insn.code.split("\n")] + trailing = insn.code.split("\n") elif isinstance(insn, lp.BarrierInstruction): lhs = "" rhs = "... %sbarrier" % insn.synchronization_kind[0] diff --git a/loopy/preprocess.py b/loopy/preprocess.py index 221233ed0..4e00eab7d 100644 --- a/loopy/preprocess.py +++ b/loopy/preprocess.py @@ -1372,7 +1372,7 @@ def realize_reduction(kernel, insn_id_filter=None, unknown_types_ok=True, track_iname = var_name_gen( "{sweep_iname}__seq_scan" - .format(scan_iname=scan_iname, sweep_iname=sweep_iname)) + .format(sweep_iname=sweep_iname)) get_or_add_sweep_tracking_iname_and_domain( scan_iname, sweep_iname, sweep_min_value, scan_min_value, @@ -1482,7 +1482,7 @@ def realize_reduction(kernel, insn_id_filter=None, unknown_types_ok=True, track_iname = var_name_gen( "{sweep_iname}__pre_scan" - .format(scan_iname=scan_iname, sweep_iname=sweep_iname)) + .format(sweep_iname=sweep_iname)) get_or_add_sweep_tracking_iname_and_domain( scan_iname, sweep_iname, sweep_min_value, scan_min_value, stride, diff --git a/loopy/symbolic.py b/loopy/symbolic.py index d3261b110..4156dfcc1 100644 --- a/loopy/symbolic.py +++ b/loopy/symbolic.py @@ -273,8 +273,7 @@ class UnidirectionalUnifier(UnidirectionalUnifierBase): if not isinstance(other, type(expr)): return self.treat_mismatch(expr, other, unis) if (expr.inames != other.inames - or type(expr.operation) != type(other.operation) # noqa - ): + or type(expr.operation) != type(other.operation)): # noqa return [] return self.rec(expr.expr, other.expr, unis) diff --git a/loopy/tools.py b/loopy/tools.py index e16bac6b2..f7e9997c1 100644 --- a/loopy/tools.py +++ b/loopy/tools.py @@ -210,11 +210,11 @@ def remove_common_indentation(code, require_leading_newline=True, test_line = None if ignore_lines_starting_with: - for l in lines: - strip_l = l.lstrip() + for line in lines: + strip_l = line.lstrip() if (strip_l and not strip_l.startswith(ignore_lines_starting_with)): - test_line = l + test_line = line break else: diff --git a/loopy/transform/iname.py b/loopy/transform/iname.py index ae717e1c7..8432d59ec 100644 --- a/loopy/transform/iname.py +++ b/loopy/transform/iname.py @@ -977,8 +977,8 @@ def _get_iname_duplication_options(insn_iname_sets, old_common_inames=frozenset( # is inspected. For each element of the power set without the # empty and the full set, one duplication option is generated. for insns_to_dup in it.chain.from_iterable( - it.combinations(iname_insns, l) - for l in range(1, len(iname_insns))): + it.combinations(iname_insns, i) + for i in range(1, len(iname_insns))): yield ( iname, tuple(insn | old_common_inames for insn in insns_to_dup)) -- GitLab