From d4dbb9b996f001729ea172d83a25ae0223285f56 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 28 Sep 2020 11:35:14 -0500 Subject: [PATCH] Enable, fix quotes linting --- .github/workflows/ci.yml | 4 ++-- .gitignore | 2 ++ .gitlab-ci.yml | 2 +- examples/curve-pot.py | 1 - examples/curve.py | 4 +--- examples/expansion-toys.py | 2 +- examples/fourier.py | 6 ------ setup.cfg | 4 ++++ setup.py | 30 +++++++++++++++--------------- sumpy/symbolic.py | 4 ++-- sumpy/tools.py | 12 ++++++------ sumpy/toys.py | 4 ++-- test/test_codegen.py | 10 +++++----- test/test_cse.py | 28 ++++++++++++++-------------- test/test_matrixgen.py | 8 ++++---- 15 files changed, 59 insertions(+), 62 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f928a7f9..af9e56b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,11 +18,11 @@ jobs: - uses: actions/setup-python@v1 with: - python-version: '3.x' + python-version: '3.x' - name: "Main Script" run: | curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-flake8.sh - . ./prepare-and-run-flake8.sh sumpy test + . ./prepare-and-run-flake8.sh "$(basename $GITHUB_REPOSITORY)" test examples docs: name: Documentation diff --git a/.gitignore b/.gitignore index e0287a53..ab75b2ee 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ doc/_build sumpy/_git_rev.py .asv + +*.vts diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 46d2468f..4de1eb46 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -95,7 +95,7 @@ Documentation: 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 sumpy test" + - . ./prepare-and-run-flake8.sh "$CI_PROJECT_NAME" test examples tags: - python3 except: diff --git a/examples/curve-pot.py b/examples/curve-pot.py index 4b0a5d44..72389fb4 100644 --- a/examples/curve-pot.py +++ b/examples/curve-pot.py @@ -231,7 +231,6 @@ def draw_pot_figure(aspect_ratio, else: # {{{ 3D plots - plotval_vol = vol_pot.real plotval_c = curve_pot.real diff --git a/examples/curve.py b/examples/curve.py index 36031c3e..17327c3d 100644 --- a/examples/curve.py +++ b/examples/curve.py @@ -6,11 +6,9 @@ import scipy as sp import scipy.fftpack - - class CurveGrid: def __init__(self, x, y): - self.pos = np.vstack([x,y]).copy() + self.pos = np.vstack([x, y]).copy() xp = self.xp = sp.fftpack.diff(x, period=1) yp = self.yp = sp.fftpack.diff(y, period=1) xpp = self.xpp = sp.fftpack.diff(xp, period=1) diff --git a/examples/expansion-toys.py b/examples/expansion-toys.py index fbae9acd..12543b93 100644 --- a/examples/expansion-toys.py +++ b/examples/expansion-toys.py @@ -28,7 +28,7 @@ def main(): plt.show() mexp = t.multipole_expand(pt_src, [0, 0], 5) - mexp2 = t.multipole_expand(mexp, [0, 0.25]) + mexp2 = t.multipole_expand(mexp, [0, 0.25]) # noqa: F841 lexp = t.local_expand(mexp, [3, 0]) lexp2 = t.local_expand(lexp, [3, 1], 3) diff --git a/examples/fourier.py b/examples/fourier.py index 4c710970..e8042225 100644 --- a/examples/fourier.py +++ b/examples/fourier.py @@ -3,8 +3,6 @@ from __future__ import absolute_import import numpy as np - - def make_fourier_vdm(n, inverse): i = np.arange(n, dtype=np.float64) imat = i[:, np.newaxis]*i/n @@ -15,8 +13,6 @@ def make_fourier_vdm(n, inverse): return result - - def make_fourier_mode_extender(m, n, dtype): k = min(m, n) result = np.zeros((m, n), dtype) @@ -36,8 +32,6 @@ def make_fourier_mode_extender(m, n, dtype): return result - - def make_fourier_interp_matrix(m, n): return np.dot( np.dot( diff --git a/setup.cfg b/setup.cfg index 77f81d3b..ff6095e6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,7 @@ [flake8] ignore = E126,E127,E128,E123,E226,E241,E242,E265,E402,W503 max-line-length=85 + +inline-quotes = " +docstring-quotes = """ +multiline-quotes = """ diff --git a/setup.py b/setup.py index 7ad7032c..ceb4d7e2 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ finally: version_file.close() os.environ["AKPYTHON_EXEC_FROM_WITHIN_WITHIN_SETUP_PY"] = "1" -exec(compile(version_file_contents, "sumpy/version.py", 'exec'), ver_dic) +exec(compile(version_file_contents, "sumpy/version.py", "exec"), ver_dic) # {{{ capture git revision at install time @@ -56,7 +56,7 @@ def write_git_revision(package_name): git_rev = find_git_revision(dn) with open(join(dn, package_name, "_git_rev.py"), "w") as outf: - outf.write("GIT_REVISION = %s\n" % repr(git_rev)) + outf.write('GIT_REVISION = "%s"\n' % git_rev) write_git_revision("sumpy") @@ -71,19 +71,19 @@ setup(name="sumpy", Code-generating FMM etc. """, classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Intended Audience :: Other Audience', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: MIT License', - 'Natural Language :: English', - 'Programming Language :: Python', - 'Topic :: Scientific/Engineering', - 'Topic :: Scientific/Engineering :: Information Analysis', - 'Topic :: Scientific/Engineering :: Mathematics', - 'Topic :: Scientific/Engineering :: Visualization', - 'Topic :: Software Development :: Libraries', - 'Topic :: Utilities', + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Intended Audience :: Other Audience", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Programming Language :: Python", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Information Analysis", + "Topic :: Scientific/Engineering :: Mathematics", + "Topic :: Scientific/Engineering :: Visualization", + "Topic :: Software Development :: Libraries", + "Topic :: Utilities", ], author="Andreas Kloeckner", diff --git a/sumpy/symbolic.py b/sumpy/symbolic.py index 7a86958a..f04293a5 100644 --- a/sumpy/symbolic.py +++ b/sumpy/symbolic.py @@ -187,11 +187,11 @@ def checked_cse(exprs, symbols=None): outf.write("%s\n\n" % max_old) outf.write("%s\n" % max_new) for i in range(len(exprs)): - outf.write("print(\"diff in expr %d:\n\");\n" % i) + outf.write('print("diff in expr %d:\n");\n' % i) outf.write("print(ratsimp(old_expr%d - new_expr%d));\n" % (i, i)) from subprocess import check_call - check_call(["maxima", "--very-quiet", "-r", "load(\"check.mac\");"]) + check_call(["maxima", "--very-quiet", "-r", 'load("check.mac");']) return new_assignments, new_exprs diff --git a/sumpy/tools.py b/sumpy/tools.py index 2a0a8b22..6003e5c4 100644 --- a/sumpy/tools.py +++ b/sumpy/tools.py @@ -492,15 +492,15 @@ class MatrixBlockIndexRanges(object): end """, [ - lp.GlobalArg('blkranges', None, shape="nranges + 1"), + lp.GlobalArg("blkranges", None, shape="nranges + 1"), lp.GlobalArg("rowindices", None, shape="nresults"), lp.GlobalArg("colindices", None, shape="nresults"), lp.ValueArg("nresults", None), - '...' + "..." ], name="block_index_knl", default_offset=lp.auto, - assumptions='nranges>=1', + assumptions="nranges>=1", silenced_warnings="write_race(write_index*)", lang_version=MOST_RECENT_LANGUAGE_VERSION) loopy_knl = lp.split_iname(loopy_knl, "irange", 128, outer_tag="g.0") @@ -576,15 +576,15 @@ class OrderedSet(MutableSet): def pop(self, last=True): if not self: - raise KeyError('set is empty') + raise KeyError("set is empty") key = self.end[1][0] if last else self.end[2][0] self.discard(key) return key def __repr__(self): if not self: - return '%s()' % (self.__class__.__name__,) - return '%s(%r)' % (self.__class__.__name__, list(self)) + return "%s()" % (self.__class__.__name__,) + return "%s(%r)" % (self.__class__.__name__, list(self)) def __eq__(self, other): if isinstance(other, OrderedSet): diff --git a/sumpy/toys.py b/sumpy/toys.py index b7d5c68d..b824d957 100644 --- a/sumpy/toys.py +++ b/sumpy/toys.py @@ -713,7 +713,7 @@ class SchematicVisitor(object): if psource.text_kwargs is not None: psource_text_kwargs_copy = psource.text_kwargs.copy() - label = psource_text_kwargs_copy.pop('s', label) + label = psource_text_kwargs_copy.pop("s", label) text_kwargs.update(psource_text_kwargs_copy) shrinkB = 0 # noqa @@ -721,7 +721,7 @@ class SchematicVisitor(object): # Avoid overlapping the tail of the arrow with any expansion labels that # are present at the tail. import matplotlib as mpl - font_size = mpl.rcParams['font.size'] + font_size = mpl.rcParams["font.size"] shrinkB = 7/8 * font_size # noqa arrowprops = dict(shrinkB=shrinkB, arrowstyle="<|-") diff --git a/test/test_codegen.py b/test/test_codegen.py index 7e3c25e0..a3683c8f 100644 --- a/test/test_codegen.py +++ b/test/test_codegen.py @@ -55,10 +55,10 @@ def test_kill_trivial_assignments(): return Sum(vals) assert result == [ - ('nt', x**y), - ('u0', _s(6, 1)), - ('u1', _s(-6, 1)), - ('u2', _s(6*x, 1))] + ("nt", x**y), + ("u0", _s(6, 1)), + ("u1", _s(-6, 1)), + ("u2", _s(6*x, 1))] def test_symbolic_assignment_name_uniqueness(): @@ -106,7 +106,7 @@ def test_line_taylor_coeff_growth(): # You can test individual routines by typing -# $ python test_fmm.py 'test_sumpy_fmm(cl.create_some_context)' +# $ python test_fmm.py "test_sumpy_fmm(cl.create_some_context)" if __name__ == "__main__": if len(sys.argv) > 1: diff --git a/test/test_cse.py b/test/test_cse.py index 2f54f34b..69501b0f 100644 --- a/test/test_cse.py +++ b/test/test_cse.py @@ -81,8 +81,8 @@ from sumpy.cse import ( cse, preprocess_for_cse, postprocess_for_cse) -w, x, y, z = symbols('w,x,y,z') -x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12 = symbols('x:13') +w, x, y, z = symbols("w,x,y,z") +x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12 = symbols("x:13") sympyonly = ( pytest.mark.skipif(USE_SYMENGINE, reason="uses a sympy-only feature")) @@ -249,8 +249,8 @@ def test_issue_4499(): # previously, this gave 16 constants from sympy.abc import a, b from sympy import Tuple, S - B = Function('B') # noqa - G = Function('G') # noqa + B = Function("B") # noqa + G = Function("G") # noqa t = Tuple( *(a, a + S(1)/2, 2*a, b, 2*a - b + 1, (sqrt(z)/2)**(-2*a + 1)*B(2*a - b, sqrt(z))*B(b - 1, sqrt(z))*G(b)*G(2*a - b + 1), # noqa @@ -278,10 +278,10 @@ def test_issue_6169(): def test_cse_Indexed(): # noqa from sympy import IndexedBase, Idx len_y = 5 - y = IndexedBase('y', shape=(len_y,)) - x = IndexedBase('x', shape=(len_y,)) - Dy = IndexedBase('Dy', shape=(len_y-1,)) # noqa - i = Idx('i', len_y-1) + y = IndexedBase("y", shape=(len_y,)) + x = IndexedBase("x", shape=(len_y,)) + Dy = IndexedBase("Dy", shape=(len_y-1,)) # noqa + i = Idx("i", len_y-1) expr1 = (y[i+1]-y[i])/(x[i+1]-x[i]) expr2 = 1/(x[i+1]-x[i]) @@ -326,17 +326,17 @@ def test_symbols_exhausted_error(): def test_issue_7840(): # daveknippers' example C393 = sympify( # noqa - 'Piecewise((C391 - 1.65, C390 < 0.5), (Piecewise((C391 - 1.65, \ - C391 > 2.35), (C392, True)), True))' + "Piecewise((C391 - 1.65, C390 < 0.5), (Piecewise((C391 - 1.65, \ + C391 > 2.35), (C392, True)), True))" ) C391 = sympify( # noqa - 'Piecewise((2.05*C390**(-1.03), C390 < 0.5), (2.5*C390**(-0.625), True))' + "Piecewise((2.05*C390**(-1.03), C390 < 0.5), (2.5*C390**(-0.625), True))" ) - C393 = C393.subs('C391',C391) # noqa + C393 = C393.subs("C391",C391) # noqa # simple substitution sub = {} - sub['C390'] = 0.703451854 - sub['C392'] = 1.01417794 + sub["C390"] = 0.703451854 + sub["C392"] = 1.01417794 ss_answer = C393.subs(sub) # cse substitutions, new_eqn = cse(C393) diff --git a/test/test_matrixgen.py b/test/test_matrixgen.py index 463e7be6..9ebce957 100644 --- a/test/test_matrixgen.py +++ b/test/test_matrixgen.py @@ -96,8 +96,8 @@ def _build_block_index(queue, nnodes, nblks, factor): cl.array.to_device(queue, ranges_).with_queue(None)) -@pytest.mark.parametrize('factor', [1.0, 0.6]) -@pytest.mark.parametrize('lpot_id', [1, 2]) +@pytest.mark.parametrize("factor", [1.0, 0.6]) +@pytest.mark.parametrize("lpot_id", [1, 2]) def test_qbx_direct(ctx_factory, factor, lpot_id): logging.basicConfig(level=logging.INFO) @@ -181,7 +181,7 @@ def test_qbx_direct(ctx_factory, factor, lpot_id): @pytest.mark.parametrize("exclude_self", [True, False]) @pytest.mark.parametrize("factor", [1.0, 0.6]) -@pytest.mark.parametrize('lpot_id', [1, 2]) +@pytest.mark.parametrize("lpot_id", [1, 2]) def test_p2p_direct(ctx_factory, exclude_self, factor, lpot_id): logging.basicConfig(level=logging.INFO) @@ -258,7 +258,7 @@ def test_p2p_direct(ctx_factory, exclude_self, factor, lpot_id): # You can test individual routines by typing -# $ python test_kernels.py 'test_p2p(cl.create_some_context)' +# $ python test_kernels.py "test_p2p(cl.create_some_context)" if __name__ == "__main__": if len(sys.argv) > 1: -- GitLab