Skip to content

Commit

Permalink
ruff: fix C409 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl authored and inducer committed Aug 11, 2024
1 parent e598a77 commit 23276e7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pytential/linalg/direct_solver_symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pytential/qbx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions pytential/symbolic/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down
2 changes: 1 addition & 1 deletion pytential/symbolic/pde/maxwell/waveguide.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion pytential/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
16 changes: 8 additions & 8 deletions test/test_symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand All @@ -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)
Expand Down

0 comments on commit 23276e7

Please sign in to comment.