From b85792f8e214384b9e77e6b72675829e82f50732 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 30 Nov 2016 15:57:53 -0600 Subject: [PATCH 1/5] Enable running Flake8 during CI --- .gitlab-ci.yml | 9 +++++++++ setup.cfg | 1 + 2 files changed, 10 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bb15d7c9f..eeb510f2f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -100,3 +100,12 @@ Documentation: - python3.5 only: - master + +Flake8: + script: + - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-flake8.sh + - ". ./prepare-and-run-flake8.sh loopy test" + tags: + - python3.5 + except: + - tags diff --git a/setup.cfg b/setup.cfg index d34ecdd6d..2a5739293 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,4 @@ [flake8] ignore = E126,E127,E128,E123,E226,E241,E242,E265,N802,W503,E402 max-line-length=85 +exclude=loopy/target/c/compyte/ndarray -- GitLab From 495b8986288b7650bcd78e2c98e067832d57995d Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 30 Nov 2016 16:13:55 -0600 Subject: [PATCH 2/5] Flake8 fixes --- loopy/__init__.py | 2 +- loopy/kernel/creation.py | 3 ++- loopy/target/python.py | 2 +- loopy/transform/data.py | 1 + loopy/transform/padding.py | 1 + setup.cfg | 4 ++-- test/gnuma_loopy_transforms.py | 4 ++-- test/library_for_test.py | 1 + test/test_domain.py | 7 +++---- test/test_from_loopy_import_star.py | 2 +- 10 files changed, 15 insertions(+), 12 deletions(-) diff --git a/loopy/__init__.py b/loopy/__init__.py index 6bd764f8d..6cbb3362e 100644 --- a/loopy/__init__.py +++ b/loopy/__init__.py @@ -457,8 +457,8 @@ def _set_up_default_target(): set_default_target(target) -_set_up_default_target() +_set_up_default_target() # }}} diff --git a/loopy/kernel/creation.py b/loopy/kernel/creation.py index 6c5491384..9962195e3 100644 --- a/loopy/kernel/creation.py +++ b/loopy/kernel/creation.py @@ -583,7 +583,8 @@ def parse_instructions(instructions, defines): new_instructions.append( insn.copy( id=intern(insn.id) if isinstance(insn.id, str) else insn.id, - depends_on=frozenset(intern_if_str(dep) for dep in insn.depends_on), + depends_on=frozenset( + intern_if_str(dep) for dep in insn.depends_on), groups=frozenset(intern(grp) for grp in insn.groups), conflicts_with_groups=frozenset( intern(grp) for grp in insn.conflicts_with_groups), diff --git a/loopy/target/python.py b/loopy/target/python.py index 09a86665b..99ec42f44 100644 --- a/loopy/target/python.py +++ b/loopy/target/python.py @@ -134,7 +134,7 @@ class ExpressionToPythonMapper(StringifyMapper): # Synthesize PREC_IFTHENELSE, make sure it is in the right place in the # operator precedence hierarchy (right above "or"). from pymbolic.mapper.stringifier import PREC_LOGICAL_OR, PREC_NONE - PREC_IFTHENELSE = PREC_LOGICAL_OR - 1 + PREC_IFTHENELSE = PREC_LOGICAL_OR - 1 # noqa return self.parenthesize_if_needed( "{then} if {cond} else {else_}".format( diff --git a/loopy/transform/data.py b/loopy/transform/data.py index 5797b01c3..6871cdbf4 100644 --- a/loopy/transform/data.py +++ b/loopy/transform/data.py @@ -431,6 +431,7 @@ def set_array_axis_names(kernel, ary_names, dim_names): return kernel + set_array_dim_names = MovedFunctionDeprecationWrapper(set_array_axis_names) # }}} diff --git a/loopy/transform/padding.py b/loopy/transform/padding.py index 915742fc1..d695e3595 100644 --- a/loopy/transform/padding.py +++ b/loopy/transform/padding.py @@ -245,6 +245,7 @@ def split_array_dim(kernel, arrays_and_axes, count, auto_split_inames=True, return kernel + split_arg_axis = MovedFunctionDeprecationWrapper(split_array_dim) # }}} diff --git a/setup.cfg b/setup.cfg index 2a5739293..f940d2653 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,4 +1,4 @@ [flake8] -ignore = E126,E127,E128,E123,E226,E241,E242,E265,N802,W503,E402 +ignore = E126,E127,E128,E123,E226,E241,E242,E265,N802,W503,E402,N814 max-line-length=85 -exclude=loopy/target/c/compyte/ndarray +exclude=loopy/target/c/compyte/ndarray,loopy/target/c/compyte/array.py diff --git a/test/gnuma_loopy_transforms.py b/test/gnuma_loopy_transforms.py index 5a55f4a3d..bb521bd2c 100644 --- a/test/gnuma_loopy_transforms.py +++ b/test/gnuma_loopy_transforms.py @@ -14,7 +14,7 @@ def pick_apart_float_cast(value): return float(fval_match.group(2)) -def fix_euler_parameters(kernel, p_p0, p_Gamma, p_R): +def fix_euler_parameters(kernel, p_p0, p_Gamma, p_R): # noqa return lp.fix_parameters( kernel, p_p0=pick_apart_float_cast(p_p0), @@ -36,7 +36,7 @@ def set_D_storage_format(kernel): return lp.tag_array_axes(kernel, "D", "f,f") -def set_up_volume_loop(kernel, Nq): +def set_up_volume_loop(kernel, Nq): # noqa kernel = lp.fix_parameters(kernel, Nq=Nq) kernel = lp.prioritize_loops(kernel, "e,k,j,i") kernel = lp.tag_inames(kernel, dict(e="g.0", j="l.1", i="l.0")) diff --git a/test/library_for_test.py b/test/library_for_test.py index b2de0d402..2cb4067e0 100644 --- a/test/library_for_test.py +++ b/test/library_for_test.py @@ -1,5 +1,6 @@ # This exists because function handles can't be pickled. + def no_ret_f_mangler(kernel, name, arg_dtypes): if not isinstance(name, str): return None diff --git a/test/test_domain.py b/test/test_domain.py index 531e79270..e01c3a937 100644 --- a/test/test_domain.py +++ b/test/test_domain.py @@ -22,8 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -import six -from six.moves import range +import six # noqa +from six.moves import range # noqa import sys import numpy as np @@ -31,7 +31,7 @@ import loopy as lp import pyopencl as cl import pyopencl.clmath # noqa import pyopencl.clrandom # noqa -import pytest +import pytest # noqa import logging logger = logging.getLogger(__name__) @@ -225,7 +225,6 @@ def test_dependent_loop_bounds_3(ctx_factory): knl = lp.preprocess_kernel(knl, ctx.devices[0]) - import pytest with pytest.raises(RuntimeError): list(lp.generate_loop_schedules(knl_bad)) diff --git a/test/test_from_loopy_import_star.py b/test/test_from_loopy_import_star.py index 02ec16044..4f339ef96 100644 --- a/test/test_from_loopy_import_star.py +++ b/test/test_from_loopy_import_star.py @@ -1 +1 @@ -from loopy import * +from loopy import * # noqa -- GitLab From 588e17d4768dfe2b8f24eea642625368fc13ad15 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 30 Nov 2016 16:19:26 -0600 Subject: [PATCH 3/5] Flake8 fixes --- loopy/kernel/__init__.py | 4 ++-- loopy/kernel/data.py | 2 +- loopy/kernel/instruction.py | 4 ++-- loopy/schedule/__init__.py | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/loopy/kernel/__init__.py b/loopy/kernel/__init__.py index e71a88886..64cf42cf7 100644 --- a/loopy/kernel/__init__.py +++ b/loopy/kernel/__init__.py @@ -1175,8 +1175,8 @@ class LoopKernel(RecordWithoutPickling): import loopy as lp - Fore = self.options._fore - Style = self.options._style + Fore = self.options._fore # noqa + Style = self.options._style # noqa from loopy.kernel.tools import draw_dependencies_as_unicode_arrows for insn, (arrows, extender) in zip( diff --git a/loopy/kernel/data.py b/loopy/kernel/data.py index b1430448d..583a341a9 100644 --- a/loopy/kernel/data.py +++ b/loopy/kernel/data.py @@ -289,7 +289,7 @@ class InameArg(ValueArg): # {{{ temporary variable -class temp_var_scope: +class temp_var_scope: # noqa """Storage location of a temporary .. attribute:: PRIVATE diff --git a/loopy/kernel/instruction.py b/loopy/kernel/instruction.py index 417ff9dd3..3a3a8f4e5 100644 --- a/loopy/kernel/instruction.py +++ b/loopy/kernel/instruction.py @@ -502,7 +502,7 @@ def _get_assignee_subscript_deps(expr): # {{{ atomic ops -class memory_ordering: +class memory_ordering: # noqa """Ordering of atomic operations, defined as in C11 and OpenCL. .. attribute:: relaxed @@ -530,7 +530,7 @@ class memory_ordering: raise ValueError("Unknown value of memory_ordering") -class memory_scope: +class memory_scope: # noqa """Scope of atomicity, defined as in OpenCL. .. attribute:: auto diff --git a/loopy/schedule/__init__.py b/loopy/schedule/__init__.py index 1031488be..593eb23b7 100644 --- a/loopy/schedule/__init__.py +++ b/loopy/schedule/__init__.py @@ -416,15 +416,15 @@ def sched_item_to_insn_id(sched_item): # {{{ debug help def format_insn_id(kernel, insn_id): - Fore = kernel.options._fore - Style = kernel.options._style + Fore = kernel.options._fore # noqa + Style = kernel.options._style # noqa return Fore.GREEN + insn_id + Style.RESET_ALL def format_insn(kernel, insn_id): insn = kernel.id_to_insn[insn_id] - Fore = kernel.options._fore - Style = kernel.options._style + Fore = kernel.options._fore # noqa + Style = kernel.options._style # noqa from loopy.kernel.instruction import ( MultiAssignmentBase, NoOpInstruction, BarrierInstruction) if isinstance(insn, MultiAssignmentBase): @@ -645,8 +645,8 @@ def generate_loop_schedules_internal( # to give loops containing high-priority instructions a chance. kernel = sched_state.kernel - Fore = kernel.options._fore - Style = kernel.options._style + Fore = kernel.options._fore # noqa + Style = kernel.options._style # noqa if allow_boost is None: rec_allow_boost = None -- GitLab From b4ccab8482a2f3b5669b8f6291e83f0ae618d683 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 30 Nov 2016 16:20:43 -0600 Subject: [PATCH 4/5] Flake8 fixes --- test/test_numa_diff.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_numa_diff.py b/test/test_numa_diff.py index c85aa80ec..0de08f5f6 100644 --- a/test/test_numa_diff.py +++ b/test/test_numa_diff.py @@ -46,7 +46,7 @@ __all__ = [ @pytest.mark.parametrize("Nq", [7]) @pytest.mark.parametrize("ilp_multiple", [1, 2]) @pytest.mark.parametrize("opt_level", [11]) -def test_gnuma_horiz_kernel(ctx_factory, ilp_multiple, Nq, opt_level): +def test_gnuma_horiz_kernel(ctx_factory, ilp_multiple, Nq, opt_level): # noqa ctx = ctx_factory() filename = "strongVolumeKernels.f90" -- GitLab From c40b4d99d55581504e240174c01911944e5f04cd Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Tue, 6 Dec 2016 09:20:46 -0600 Subject: [PATCH 5/5] More Flake8 fixes --- loopy/kernel/data.py | 3 +-- setup.cfg | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/loopy/kernel/data.py b/loopy/kernel/data.py index 7ebb33849..5195e0a10 100644 --- a/loopy/kernel/data.py +++ b/loopy/kernel/data.py @@ -404,8 +404,7 @@ class TemporaryVariable(ArrayBase): if base_indices is None: base_indices = (0,) * len(shape) - if (not read_only - and initializer is not None): + if not read_only and initializer is not None: raise LoopyError( "temporary variable '%s': " "read-write variables with initializer " diff --git a/setup.cfg b/setup.cfg index f940d2653..56341fa98 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,4 +1,8 @@ [flake8] ignore = E126,E127,E128,E123,E226,E241,E242,E265,N802,W503,E402,N814 max-line-length=85 -exclude=loopy/target/c/compyte/ndarray,loopy/target/c/compyte/array.py +exclude= + loopy/target/c/compyte/ndarray, + loopy/target/c/compyte/array.py, + loopy/statistics.py, + test/test_statistics.py -- GitLab