From 23276e792e4cd8bfbae87a4017e0b7953eb40ed4 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Sun, 11 Aug 2024 16:15:41 +0300 Subject: [PATCH] ruff: fix C409 errors --- pytential/linalg/direct_solver_symbolic.py | 2 +- pytential/qbx/__init__.py | 4 ++-- pytential/symbolic/execution.py | 8 ++++---- pytential/symbolic/pde/maxwell/waveguide.py | 2 +- pytential/version.py | 2 +- test/test_symbolic.py | 16 ++++++++-------- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pytential/linalg/direct_solver_symbolic.py b/pytential/linalg/direct_solver_symbolic.py index 0215e694a..c5f523930 100644 --- a/pytential/linalg/direct_solver_symbolic.py +++ b/pytential/linalg/direct_solver_symbolic.py @@ -88,7 +88,7 @@ def __init__(self): def map_int_g(self, expr): target_kernel = self.txr(expr.target_kernel) - source_kernels = tuple([self.sxr(kernel) for kernel in expr.source_kernels]) + source_kernels = tuple(self.sxr(kernel) for kernel in expr.source_kernels) if (target_kernel == expr.target_kernel and source_kernels == expr.source_kernels): return expr diff --git a/pytential/qbx/__init__.py b/pytential/qbx/__init__.py index f2912b9ce..03ee21f73 100644 --- a/pytential/qbx/__init__.py +++ b/pytential/qbx/__init__.py @@ -834,13 +834,13 @@ def _flat_centers(dofdesc, qbx_forced_limit): assert o.qbx_forced_limit is not None assert abs(o.qbx_forced_limit) > 0 - self_outputs[(o.target_name, o.qbx_forced_limit)].append((i, o)) + self_outputs[o.target_name, o.qbx_forced_limit].append((i, o)) else: qbx_forced_limit = o.qbx_forced_limit if qbx_forced_limit is None: qbx_forced_limit = 0 - other_outputs[(o.target_name, qbx_forced_limit)].append((i, o)) + other_outputs[o.target_name, qbx_forced_limit].append((i, o)) queue = actx.queue results = [None] * len(insn.outputs) diff --git a/pytential/symbolic/execution.py b/pytential/symbolic/execution.py index 505460767..3efbee43c 100644 --- a/pytential/symbolic/execution.py +++ b/pytential/symbolic/execution.py @@ -172,15 +172,15 @@ def element_knl(): operand = self.rec(expr.operand) if dofdesc.granularity is sym.GRANULARITY_NODE: - return type(operand)(actx, tuple([ + return type(operand)(actx, tuple( actx.call_loopy(node_knl(), operand=operand_i)["result"] for operand_i in operand - ])) + )) elif dofdesc.granularity is sym.GRANULARITY_ELEMENT: - return type(operand)(actx, tuple([ + return type(operand)(actx, tuple( actx.call_loopy(element_knl(), operand=operand_i)["result"] for operand_i in operand - ])) + )) else: raise ValueError(f"unsupported granularity: {dofdesc.granularity}") diff --git a/pytential/symbolic/pde/maxwell/waveguide.py b/pytential/symbolic/pde/maxwell/waveguide.py index 1049d2674..14dde8969 100644 --- a/pytential/symbolic/pde/maxwell/waveguide.py +++ b/pytential/symbolic/pde/maxwell/waveguide.py @@ -99,7 +99,7 @@ def unknown_index(self): for i in range(len(self.interfaces)): for current in ["j", "m"]: for cur_dir in ["z", "t"]: - result[(current + cur_dir, i)] = len(result) + result[current + cur_dir, i] = len(result) return result diff --git a/pytential/version.py b/pytential/version.py index e48b29f90..6fa7fde4b 100644 --- a/pytential/version.py +++ b/pytential/version.py @@ -25,7 +25,7 @@ from pytools import find_module_git_revision VERSION_TEXT = metadata.version("pytential") -VERSION = tuple([int(i) for i in VERSION_TEXT.split(".")]) +VERSION = tuple(int(i) for i in VERSION_TEXT.split(".")) _GIT_REVISION = find_module_git_revision(__file__, n_levels_up=1) PYTENTIAL_KERNEL_VERSION = (*VERSION, _GIT_REVISION, 0) diff --git a/test/test_symbolic.py b/test/test_symbolic.py index 305ee6e1e..a5e97badc 100644 --- a/test/test_symbolic.py +++ b/test/test_symbolic.py @@ -320,10 +320,10 @@ def randrange_like(xi, offset): from meshmode.dof_array import DOFArray base_node_nrs = np.cumsum([0] + [grp.ndofs for grp in discr.groups]) - ary = DOFArray(actx, tuple([ + ary = DOFArray(actx, data=tuple( randrange_like(xi, offset) for xi, offset in zip(discr.nodes()[0], base_node_nrs) - ])) + )) n = discr.ndofs for func, expected in [ @@ -336,27 +336,27 @@ def randrange_like(xi, offset): ) assert r == expected, (r, expected) - arys = tuple([rng.random(size=xi.shape) for xi in ary]) - x = DOFArray(actx, tuple([actx.from_numpy(xi) for xi in arys])) + arys = tuple(rng.random(size=xi.shape) for xi in ary) + x = DOFArray(actx, data=tuple(actx.from_numpy(xi) for xi in arys)) from meshmode.dof_array import flat_norm for func, np_func in [ (sym.ElementwiseSum, np.sum), (sym.ElementwiseMax, np.max) ]: - expected = DOFArray(actx, tuple([ + expected = DOFArray(actx, data=tuple( actx.from_numpy(np.tile(np_func(xi, axis=1, keepdims=True), xi.shape[1])) for xi in arys - ])) + )) r = bind( discr, func(sym.var("x"), dofdesc=sym.GRANULARITY_NODE) )(actx, x=x) assert actx.to_numpy(flat_norm(r - expected)) < 1.0e-15 - expected = DOFArray(actx, tuple([ + expected = DOFArray(actx, data=tuple( actx.from_numpy(np_func(xi, axis=1, keepdims=True)) for xi in arys - ])) + )) r = bind( discr, func(sym.var("x"), dofdesc=sym.GRANULARITY_ELEMENT) )(actx, x=x)