From bbc5e2f31c2a757909cce2a0de768ea86691ca20 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 25 Oct 2018 10:42:08 -0500 Subject: [PATCH] Placate modern Flake8 --- pymbolic/algorithm.py | 2 +- pymbolic/geometric_algebra/__init__.py | 3 +-- pymbolic/imperative/statement.py | 3 +-- pymbolic/mapper/__init__.py | 8 ++++---- pymbolic/mapper/differentiator.py | 6 +++--- pymbolic/mapper/stringifier.py | 4 ++-- test/test_pymbolic.py | 2 +- 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/pymbolic/algorithm.py b/pymbolic/algorithm.py index 0fb0464..18cb09e 100644 --- a/pymbolic/algorithm.py +++ b/pymbolic/algorithm.py @@ -281,7 +281,7 @@ def gaussian_elimination(mat, rhs): for i in range(m): g = gcd_many(*( [a for a in mat[i] if a] - + + + # noqa: W504 [a for a in rhs[i] if a])) mat[i] //= g diff --git a/pymbolic/geometric_algebra/__init__.py b/pymbolic/geometric_algebra/__init__.py index 5b5f0ff..4d3e54d 100644 --- a/pymbolic/geometric_algebra/__init__.py +++ b/pymbolic/geometric_algebra/__init__.py @@ -211,8 +211,7 @@ class Space(object): from pytools import all if not ( len(metric_matrix.shape) == 2 - and - all(dim == len(basis) for dim in metric_matrix.shape)): + and all(dim == len(basis) for dim in metric_matrix.shape)): raise ValueError("metric_matrix has the wrong shape") self.basis_names = basis diff --git a/pymbolic/imperative/statement.py b/pymbolic/imperative/statement.py index 0962f84..c8f27b6 100644 --- a/pymbolic/imperative/statement.py +++ b/pymbolic/imperative/statement.py @@ -116,8 +116,7 @@ class ConditionalStatement(Statement): dep_mapper = self.get_dependency_mapper() return ( super(ConditionalStatement, self).get_read_variables() - | - frozenset( + | frozenset( dep.name for dep in dep_mapper(self.condition))) # }}} diff --git a/pymbolic/mapper/__init__.py b/pymbolic/mapper/__init__.py index cdd4ba6..a280d51 100644 --- a/pymbolic/mapper/__init__.py +++ b/pymbolic/mapper/__init__.py @@ -197,8 +197,8 @@ class CombineMapper(RecursiveMapper): def map_call(self, expr, *args, **kwargs): return self.combine( - (self.rec(expr.function, *args, **kwargs),) + - tuple( + (self.rec(expr.function, *args, **kwargs),) + + tuple( self.rec(child, *args, **kwargs) for child in expr.parameters) ) @@ -242,8 +242,8 @@ class CombineMapper(RecursiveMapper): def map_polynomial(self, expr, *args, **kwargs): return self.combine( - (self.rec(expr.base, *args, **kwargs),) + - tuple( + (self.rec(expr.base, *args, **kwargs),) + + tuple( self.rec(coeff, *args, **kwargs) for exp, coeff in expr.data) ) diff --git a/pymbolic/mapper/differentiator.py b/pymbolic/mapper/differentiator.py index 95c7bd8..86ac2f9 100644 --- a/pymbolic/mapper/differentiator.py +++ b/pymbolic/mapper/differentiator.py @@ -113,9 +113,9 @@ class DifferentiationMapper(pymbolic.mapper.RecursiveMapper): def map_product(self, expr, *args): return pymbolic.flattened_sum( pymbolic.flattened_product( - [self.rec_undiff(ch, *args) for ch in expr.children[0:i]] + - [self.rec(child, *args)] + - [self.rec_undiff(ch, *args) for ch in expr.children[i+1:]] + [self.rec_undiff(ch, *args) for ch in expr.children[0:i]] + + [self.rec(child, *args)] + + [self.rec_undiff(ch, *args) for ch in expr.children[i+1:]] ) for i, child in enumerate(expr.children)) diff --git a/pymbolic/mapper/stringifier.py b/pymbolic/mapper/stringifier.py index 26c2932..7c680ef 100644 --- a/pymbolic/mapper/stringifier.py +++ b/pymbolic/mapper/stringifier.py @@ -151,7 +151,7 @@ class StringifyMapper(pymbolic.mapper.Mapper): args_strings = ( tuple(self.rec(ch, PREC_NONE, *args, **kwargs) for ch in expr.parameters) - + + + # noqa: W504 tuple("%s=%s" % (name, self.rec(ch, PREC_NONE, *args, **kwargs)) for name, ch in expr.kw_parameters.items())) return self.format("%s(%s)", @@ -681,7 +681,7 @@ class LaTeXMapper(StringifyMapper): "%s=%s" % (name, self.rec(val, PREC_NONE, *args, **kwargs)) for name, val in zip(expr.variables, expr.values)) - return self.format("[%s]\{%s\}", + return self.format(r"[%s]\{%s\}", self.rec(expr.child, PREC_NONE, *args, **kwargs), substs) diff --git a/test/test_pymbolic.py b/test/test_pymbolic.py index 5df2184..09d2e7b 100644 --- a/test/test_pymbolic.py +++ b/test/test_pymbolic.py @@ -511,7 +511,7 @@ def test_latex_mapper(): def add(expr): # Add an equation to the list of tests. - equations.append("\[%s\] %% from: %s" % (tm(expr), sm(expr))) + equations.append(r"\[%s\] %% from: %s" % (tm(expr), sm(expr))) add(parse("a * b + c")) add(parse("f(a,b,c)")) -- GitLab