From 61dbaa0ed777a15b55fcb014325aef39ed4fd4e8 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Mon, 28 Sep 2020 10:11:53 -0500 Subject: [PATCH] Enable quotes linting, plus various linter fixes --- .gitlab-ci.yml | 4 ++-- examples/dg_tools.py | 29 ++++++++--------------------- pytato/visualization.py | 14 +++++++------- setup.cfg | 4 ++++ 4 files changed, 21 insertions(+), 30 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cb8d11e..43ad52b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,7 +35,7 @@ Pylint: - export PY_EXE=python3 - EXTRA_INSTALL="pyopencl" - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-pylint.sh - - ". ./prepare-and-run-pylint.sh ${CI_PROJECT_NAME} test/test_*.py" + - . ./prepare-and-run-pylint.sh ${CI_PROJECT_NAME} test/test_*.py examples tags: - python3 except: @@ -45,7 +45,7 @@ Pylint: 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 ${CI_PROJECT_NAME} test" + - . ./prepare-and-run-flake8.sh ${CI_PROJECT_NAME} test examples tags: - python3 except: diff --git a/examples/dg_tools.py b/examples/dg_tools.py index 47ee6fb..5126bef 100644 --- a/examples/dg_tools.py +++ b/examples/dg_tools.py @@ -88,16 +88,16 @@ class DGDiscr1D(object): Signature: ->() """ - return self.elements[0,1] - self.elements[0,0] + return self.elements[0, 1] - self.elements[0, 0] def nodes(self): """Return the vector of node coordinates. Signature: ->(n*m,) """ - centers = (self.elements[:,0] + self.elements[:,1]) / 2 - radii = (self.elements[:,1] - self.elements[:,0]) / 2 - return ((self.ref_nodes[:,np.newaxis] * radii) + centers).T.ravel() + centers = (self.elements[:, 0] + self.elements[:, 1]) / 2 + radii = (self.elements[:, 1] - self.elements[:, 0]) / 2 + return ((self.ref_nodes[:, np.newaxis] * radii) + centers).T.ravel() @property @memoized @@ -155,11 +155,11 @@ class DGDiscr1D(object): Signature: ->(n, n) """ - VrT = [] + VrT = [] # noqa: N806 for row in np.eye(self.nnodes): deriv = ortholegder(row) VrT.append(ortholegval(self.ref_nodes, deriv)) - Vr = np.vstack(VrT).T + Vr = np.vstack(VrT).T # noqa: N806 return Vr @ la.inv(self.vdm) @property @@ -205,8 +205,8 @@ class DGDiscr1D(object): Signature: ->(m, 2) """ result = np.zeros((self.nelements, 2)) - result[:,0] = -1 - result[:,1] = 1 + result[:, 0] = -1 + result[:, 1] = 1 return result @@ -326,19 +326,6 @@ class AbstractDGOps1D(object): raise NotImplementedError -def elementwise(mat, vec): - """Apply a matrix to rows of the input representing per-element - degrees of freedom. - - Inputs: - mat: Shape (a, b) - vec: Shape (c, b) - - Signature: (a, b), (c, b) -> (c, a) - """ - return np.einsum("ij,kj->ki", mat, vec) - - class DGOps1DRef(AbstractDGOps1D): """A reference NumPy implementation of the AbstractDGOps1D interface.""" diff --git a/pytato/visualization.py b/pytato/visualization.py index 7739218..da02fd8 100644 --- a/pytato/visualization.py +++ b/pytato/visualization.py @@ -151,10 +151,10 @@ class DotEmitter(CodeGeneratorBase): def _emit_array(emit: DotEmitter, info: DotNodeInfo, id: str) -> None: - td_attrib = "border=\"0\"" - table_attrib = "border=\"0\" cellborder=\"1\" cellspacing=\"0\"" + td_attrib = 'border="0"' + table_attrib = 'border="0" cellborder="1" cellspacing="0"' - rows = ["%s" + rows = ['%s' % (td_attrib, dot_escape(info.title))] for name, field in info.fields.items(): @@ -173,11 +173,11 @@ def _emit_name_cluster(emit: DotEmitter, names: Mapping[str, Array], with emit.block("subgraph cluster_%s" % label): emit("node [shape=ellipse]") - emit("label=\"%s\"" % label) + emit('label="%s"' % label) for name, array in names.items(): name_id = id_gen(label) - emit("%s [label=\"%s\"]" % (name_id, dot_escape(name))) + emit('%s [label="%s"]' % (name_id, dot_escape(name))) array_id = array_to_id[array] # Edges must be outside the cluster. edges.append((name_id, array_id)) @@ -222,7 +222,7 @@ def get_dot_graph(result: Union[Array, DictOfNamedArrays]) -> str: # Emit inputs. with emit.block("subgraph cluster_Inputs"): - emit("label=\"Inputs\"") + emit('label="Inputs"') for array in input_arrays: _emit_array(emit, nodes[array], array_to_id[array]) @@ -235,7 +235,7 @@ def get_dot_graph(result: Union[Array, DictOfNamedArrays]) -> str: for label, tail_array in node.edges.items(): tail = array_to_id[tail_array] head = array_to_id[array] - emit("%s -> %s [label=\"%s\"]" % (tail, head, dot_escape(label))) + emit('%s -> %s [label="%s"]' % (tail, head, dot_escape(label))) # Emit output/namespace name mappings. _emit_name_cluster(emit, outputs, array_to_id, id_gen, label="Outputs") diff --git a/setup.cfg b/setup.cfg index b0d0924..726eb08 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,6 +2,10 @@ ignore = E126,E127,E128,E123,E226,E241,E242,E265,N802,W503,E402,N814,N817,W504 max-line-length=85 +inline-quotes = " +docstring-quotes = """ +multiline-quotes = """ + [mypy-pytato.transform] disallow_subclassing_any = False -- GitLab