diff --git a/loopy/cli.py b/loopy/cli.py index a92922b1845d76dd7a700a93c05de3eecf8c28dd..cdc24800be0edf3935aacccdd4dc4d9905cf5965 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 e9de52eb68bd47aec09b0a19de0a5d5433aa9843..7319b16ac2fe9f39872558a3878161b89cab15d9 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 5e0747246160ddc2934c3d545c03a2a9b4090d5d..c0ca875c0e9b661becb1bb0ca6e81139a8a93e2d 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 05b0a92050a51be1cd980648325921fbf13768d8..40202d4da3319c0ef24b0317f01cd4d31f88d484 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 9e54bc25d09d031e5907f68f8b8fb34dfadad94a..ac1e00bae4c16a66ac2eedd3c6fdc618894eb027 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 221233ed010e4cd3c574cf047f73263063152d93..4e00eab7d7abc600ce987b1dfa8379be5e86c3ef 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 d3261b110eef73eb34769e8702af272875613c2c..4156dfcc1673d176ffb609cf280b28c97cc4949f 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 e16bac6b28d4800a6f15072885cf7366e4e40836..f7e9997c1d3a650d14bf0a32b8b8c576cc19e16b 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 ae717e1c7550b697c23b9d032fd795c362e387f0..8432d59ec5b162f6e963abbeae3b2fcabe94cf27 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))