diff --git a/pymbolic/algorithm.py b/pymbolic/algorithm.py index 0fb0464b760a7e68fef80812ee4c366072ebc246..18cb09e548bac0d3dd50e68be5087723f5444a9f 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 5b5f0ffcf68c01b5e0761e3e4d581dae66ef50d8..4d3e54de4c185e2dcea3e69ad901e84704fb3143 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 0962f840d395a29c0afcdfca3a737f18c228ab8e..c8f27b616a99cc9e1ab38cb6e6fd53658d7095e7 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 cdd4ba699d372fca360689c5b1b310e6580e42ec..a280d51fff434729c6b7a56437307acf9c240b4f 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 95c7bd8f2581f1aa51432b4b9686e8e3c721df22..86ac2f9bbadb82955e0a581f2b97f136f434e071 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 26c2932342a6ae9d28b1f7d4f88ea8ab4729c789..7c680ef002616092616caed6029476e75ad06933 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 5df21846f8bfe5dd22132c20e93248ef2adcf6fe..09d2e7b5f667c66a5d81083f8ee59a9ba9f3346f 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)"))