Skip to content

Commit 6251b61

Browse files
committed
Fix ruff C409 failures
1 parent 66a202d commit 6251b61

File tree

6 files changed

+17
-20
lines changed

6 files changed

+17
-20
lines changed

arraycontext/container/arithmetic.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -413,9 +413,8 @@ def is_numpy_array(arg):
413413
for i, bct in enumerate(bcast_container_types):
414414
gen(f"from {bct.__module__} import {bct.__qualname__} as _bctype{i}")
415415
gen("")
416-
outer_bcast_type_names = tuple([
417-
f"_bctype{i}" for i in range(len(bcast_container_types))
418-
])
416+
outer_bcast_type_names = tuple(
417+
f"_bctype{i}" for i in range(len(bcast_container_types)))
419418
if bcast_number:
420419
outer_bcast_type_names += ("Number",)
421420

arraycontext/context.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ def einsum(self,
475475
:return: the output of the einsum :mod:`loopy` program
476476
"""
477477
if arg_names is None:
478-
arg_names = tuple([f"arg{i}" for i in range(len(args))])
478+
arg_names = tuple(f"arg{i}" for i in range(len(args)))
479479

480480
prg = self._get_einsum_prg(spec, arg_names, tagged)
481481
out_ary = self.call_loopy(

arraycontext/impl/pytato/compile.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,19 @@ def _get_f_placeholder_args(arg, kw, arg_id_to_name, actx):
214214
:attr:`BaseLazilyCompilingFunctionCaller.f`.
215215
"""
216216
if np.isscalar(arg):
217-
name = arg_id_to_name[(kw,)]
217+
name = arg_id_to_name[kw,]
218218
return pt.make_placeholder(name, (), np.dtype(type(arg)))
219219
elif isinstance(arg, pt.Array):
220-
name = arg_id_to_name[(kw,)]
220+
name = arg_id_to_name[kw,]
221221
# Transform the DAG to give metadata inference a chance to do its job
222222
arg = _to_input_for_compiled(arg, actx)
223223
return pt.make_placeholder(name, arg.shape, arg.dtype,
224224
axes=arg.axes,
225225
tags=arg.tags)
226226
elif is_array_container_type(arg.__class__):
227227
def _rec_to_placeholder(keys, ary):
228-
name = arg_id_to_name[(kw, *keys)]
228+
index = (kw, *keys)
229+
name = arg_id_to_name[index]
229230
# Transform the DAG to give metadata inference a chance to do its job
230231
ary = _to_input_for_compiled(ary, actx)
231232
return pt.make_placeholder(name,

arraycontext/pytest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def inner(metafunc):
396396

397397
# NOTE: sorts the args so that parallel pytest works
398398
arg_value_tuples = sorted([
399-
tuple([arg_dict[name] for name in arg_names])
399+
tuple(arg_dict[name] for name in arg_names)
400400
for arg_dict in arg_values_with_actx
401401
], key=lambda x: str(x))
402402

arraycontext/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def _parse_version(version: str) -> Tuple[Tuple[int, ...], str]:
88
m = re.match("^([0-9.]+)([a-z0-9]*?)$", VERSION_TEXT)
99
assert m is not None
1010

11-
return tuple([int(nr) for nr in m.group(1).split(".")]), m.group(2)
11+
return tuple(int(nr) for nr in m.group(1).split(".")), m.group(2)
1212

1313

1414
VERSION_TEXT = metadata.version("arraycontext")

test/test_arraycontext.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ def size(self):
170170

171171
@property
172172
def real(self):
173-
return DOFArray(self.array_context, tuple([subary.real for subary in self]))
173+
return DOFArray(self.array_context, tuple(subary.real for subary in self))
174174

175175
@property
176176
def imag(self):
177-
return DOFArray(self.array_context, tuple([subary.imag for subary in self]))
177+
return DOFArray(self.array_context, tuple(subary.imag for subary in self))
178178

179179

180180
@serialize_container.register(DOFArray)
@@ -258,9 +258,8 @@ def _get_test_containers(actx, ambient_dim=2, shapes=50_000):
258258
if isinstance(shapes, (Number, tuple)):
259259
shapes = [shapes]
260260

261-
x = DOFArray(actx, tuple([
262-
actx.from_numpy(randn(shape, np.float64))
263-
for shape in shapes]))
261+
x = DOFArray(actx, tuple(actx.from_numpy(randn(shape, np.float64))
262+
for shape in shapes))
264263

265264
# pylint: disable=unexpected-keyword-arg, no-value-for-parameter
266265
dataclass_of_dofs = MyContainer(
@@ -1081,13 +1080,11 @@ def test_flatten_array_container(actx_factory, shapes):
10811080
if isinstance(shapes, (int, tuple)):
10821081
shapes = [shapes]
10831082

1084-
ary = DOFArray(actx, tuple([
1085-
actx.from_numpy(randn(shape, np.float64))
1086-
for shape in shapes]))
1083+
ary = DOFArray(actx, tuple(actx.from_numpy(randn(shape, np.float64))
1084+
for shape in shapes))
10871085

1088-
template = DOFArray(actx, tuple([
1089-
actx.from_numpy(randn(shape, np.complex128))
1090-
for shape in shapes]))
1086+
template = DOFArray(actx, tuple(actx.from_numpy(randn(shape, np.complex128))
1087+
for shape in shapes))
10911088

10921089
flat = flatten(ary, actx)
10931090
ary_roundtrip = unflatten(template, flat, actx, strict=False)

0 commit comments

Comments
 (0)