Skip to content

Commit fdfa2ed

Browse files
flake8 contrib and proto-tests (#689)
* flake8 contrib and proto-tests * add to CI
1 parent 8a2b06b commit fdfa2ed

File tree

8 files changed

+212
-259
lines changed

8 files changed

+212
-259
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: "Main Script"
2222
run: |
2323
curl -L -O https://gitlab.tiker.net/inducer/ci-support/raw/main/prepare-and-run-flake8.sh
24-
. ./prepare-and-run-flake8.sh "$(basename $GITHUB_REPOSITORY)" ./test examples
24+
. ./prepare-and-run-flake8.sh "$(basename $GITHUB_REPOSITORY)" ./test examples proto-tests contrib
2525
2626
pylint:
2727
name: Pylint

contrib/c-integer-semantics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def main():
8080
with open("int-experiments.c", "w") as outf:
8181
outf.write(C_SRC)
8282

83-
system('gcc -Wall -shared int-experiments.c -o int-experiments.so')
83+
system("gcc -Wall -shared int-experiments.c -o int-experiments.so")
8484

8585
int_exp = ctypes.CDLL("int-experiments.so")
8686
for func in [

contrib/mem-pattern-explorer/pattern_vis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(self, gsize, lsize, subgroup_size=32, decay_constant=0.75):
2626

2727
self.arrays = []
2828

29-
def l(self, index): # noqa: E743
29+
def l(self, index): # noqa: E741,E743
3030
subscript = [np.newaxis] * self.ind_length
3131
subscript[len(self.gsize) + index] = slice(None)
3232

@@ -125,7 +125,7 @@ def reshape_ind(ind):
125125
lin_index = np.array(lin_index)[subscript]
126126

127127
self.array[lin_index, 0] = self.ctx.timestamp
128-
for i, glength in enumerate(self.ctx.gsize):
128+
for i, _glength in enumerate(self.ctx.gsize):
129129
if lin_index.shape[i] > 1:
130130
self.array[lin_index, 2+i] = self.ctx.g(i)
131131

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
from urllib.request import urlopen
33

4-
_conf_url = "https://raw.githubusercontent.com/inducer/sphinxconfig/main/sphinxconfig.py"
4+
_conf_url = "https://raw.githubusercontent.com/inducer/sphinxconfig/main/sphinxconfig.py" # noqa
55
with urlopen(_conf_url) as _inf:
66
exec(compile(_inf.read(), _conf_url, "exec"), globals())
77

proto-tests/test_fem_assembly.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
11
import numpy as np
2-
import pyopencl as cl
2+
import pyopencl as cl # noqa
33
import loopy as lp
44

55
from pyopencl.tools import pytest_generate_tests_for_pyopencl \
6-
as pytest_generate_tests
7-
8-
6+
as pytest_generate_tests # noqa
97

108

119
def test_laplacian_stiffness(ctx_factory):
1210
dtype = np.float32
1311
ctx = ctx_factory()
1412
order = "C"
1513

16-
dim = 2 # (baked into code)
14+
dim = 2 # (baked into code)
1715

18-
Nq = 40 # num. quadrature points (baked into code)
19-
Nb = 20 # num. basis functions (baked into code)
20-
Nc = 100 # num. cells (run-time symbolic)
16+
Nq = 40 # num. quadrature points (baked into code) # noqa
17+
Nb = 20 # num. basis functions (baked into code) # noqa
18+
Nc = 100 # num. cells (run-time symbolic) # noqa
2119

2220
from pymbolic import var
23-
Nc_sym = var("Nc")
21+
Nc_sym = var("Nc") # noqa
2422

2523
knl = lp.make_kernel(ctx.devices[0],
26-
"[Nc] -> {[K,i,j,q, dx_axis, ax_b]: 0<=K<Nc and 0<=i,j<%(Nb)d and 0<=q<%(Nq)d "
24+
"[Nc] -> {[K,i,j,q, dx_axis, ax_b]: 0<=K<Nc and 0<=i,j<%(Nb)d and 0<=q<%(Nq)d " # noqa
2725
"and 0<= dx_axis, ax_b < %(dim)d}"
2826
% dict(Nb=Nb, Nq=Nq, dim=dim),
2927
[
3028
"dPsi(ij, dxi) := sum_float32(@ax_b,"
31-
" jacInv[ax_b,dxi,K,q] * DPsi[ax_b,ij,q])",
29+
" jacInv[ax_b,dxi,K,q] * DPsi[ax_b,ij,q])", # noqa
3230
"A[K, i, j] = sum_float32(q, w[q] * jacDet[K,q] * ("
3331
"sum_float32(dx_axis, dPsi$one(i,dx_axis)*dPsi$two(j,dx_axis))))"
3432
],
@@ -55,15 +53,15 @@ def variant_pg4(knl):
5553
# This (mostly) reproduces the unlabeled code snippet on pg. 4.
5654

5755
knl = lp.tag_inames(knl, {"dx_axis": "unr"})
58-
Ncloc = 16
56+
Ncloc = 16 # noqa
5957
knl = lp.split_iname(knl, "K", Ncloc,
6058
outer_iname="Ko", inner_iname="Kloc")
6159
return knl, ["Ko", "Kloc", "i", "j", "q", "ax_b_insn"]
6260

6361
def variant_fig32(knl):
6462
# This (mostly) reproduces Figure 3.2.
6563

66-
Ncloc = 16
64+
Ncloc = 16 # noqa
6765
knl = lp.split_iname(knl, "K", Ncloc,
6866
outer_iname="Ko", inner_iname="Kloc")
6967
knl = lp.precompute(knl, "dPsi", np.float32, ["i", "q", "dx_axis"],
@@ -74,10 +72,10 @@ def variant_fig32(knl):
7472
def variant_fig33(knl):
7573
# This is meant to (mostly) reproduce Figure 3.3.
7674

77-
Ncloc = 16
75+
Ncloc = 16 # noqa
7876
knl = lp.split_iname(knl, "K", Ncloc,
7977
outer_iname="Ko", inner_iname="Kloc")
80-
knl = lp.precompute(knl, "dPsi$one", np.float32, ["dx_axis"], default_tag=None)
78+
knl = lp.precompute(knl, "dPsi$one", np.float32, ["dx_axis"], default_tag=None) # noqa
8179
knl = lp.tag_inames(knl, {"j": "ilp.seq"})
8280

8381
return knl, ["Ko", "Kloc"]
@@ -90,7 +88,7 @@ def variant_simple_gpu(knl):
9088
# help, too. :)
9189

9290
knl = lp.tag_inames(knl, {"dx_axis": "unr"})
93-
Ncloc = 16
91+
Ncloc = 16 # noqa
9492
knl = lp.split_iname(knl, "K", Ncloc,
9593
outer_iname="Ko", inner_iname="Kloc",
9694
outer_tag="g.0")
@@ -105,7 +103,7 @@ def variant_simple_gpu_prefetch(knl):
105103
# fix that. (FIXME)
106104

107105
knl = lp.tag_inames(knl, {"dx_axis": "unr"})
108-
Ncloc = 16
106+
Ncloc = 16 # noqa
109107
knl = lp.split_iname(knl, "K", Ncloc,
110108
outer_iname="Ko", inner_iname="Kloc",
111109
outer_tag="g.0")
@@ -132,13 +130,10 @@ def variant_simple_gpu_prefetch(knl):
132130
parameters={"Nc": Nc}, print_ref_code=True)
133131

134132

135-
136-
137133
if __name__ == "__main__":
138134
import sys
139135
if len(sys.argv) > 1:
140136
exec(sys.argv[1])
141137
else:
142138
from py.test.cmdline import main
143139
main([__file__])
144-

0 commit comments

Comments
 (0)