Skip to content

Commit f187d61

Browse files
committed
Placate ruff 0.16.5
1 parent 5e92d58 commit f187d61

11 files changed

Lines changed: 37 additions & 40 deletions

File tree

‎arraycontext/container/arithmetic.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ def {fname}(arg2, arg1):
738738
code = gen.get().rstrip()+"\n"
739739

740740
result_dict = {"_MODULE_SOURCE_CODE": code, "cls": cls}
741-
exec(compile(code, f"<container arithmetic for {cls.__name__}>", "exec"), # ruff:ignore[exec-builtin]
741+
exec(compile(code, f"<container arithmetic for {cls.__name__}>", "exec"),
742742
result_dict)
743743

744744
return cls

‎arraycontext/container/dataclass.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def _deserialize_init_arrays_code_{lower_cls_name}(
247247
""")
248248

249249
exec_dict = {"cls": cls, "_MODULE_SOURCE_CODE": serialize_code}
250-
exec(compile(serialize_code, f"<container serialization for {cls.__name__}>", # ruff:ignore[exec-builtin]
250+
exec(compile(serialize_code, f"<container serialization for {cls.__name__}>",
251251
"exec"), exec_dict)
252252

253253
return cls

‎arraycontext/container/traversal.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ def treat_as_scalar(x: ArrayOrContainerOrScalar) -> bool:
12091209
raise TypeError(
12101210
"both arguments must have the same type if they are both "
12111211
"non-object-array array containers.")
1212-
return multimap_array_container(lambda x, y: outer(x, y), a, b)
1212+
return multimap_array_container(outer, a, b)
12131213

12141214
# }}}
12151215

‎arraycontext/context.py‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -495,15 +495,11 @@ def _get_csr_matmul_prg(self, out_ndim: int) -> loopy.TranslationUnit:
495495
out_shape_comp_names = ("nrows", *out_extra_shape_comp_names)
496496

497497
domains: list[str] = []
498-
domains.append(
499-
"{ [" + ",".join(out_inames) + "] : "
500-
+ " and ".join(
501-
f"0 <= {iname} < {shape_comp_name}"
502-
for iname, shape_comp_name in zip(
503-
out_inames, out_shape_comp_names, strict=True))
504-
+ " }")
505-
domains.append(
506-
"{ [iel] : iel_lbound <= iel < iel_ubound }")
498+
domains.extend(("{ [" + ",".join(out_inames) + "] : " + " and ".join(
499+
f"0 <= {iname} < {shape_comp_name}"
500+
for iname, shape_comp_name
501+
in zip(out_inames, out_shape_comp_names, strict=True))
502+
+ " }", "{ [iel] : iel_lbound <= iel < iel_ubound }"))
507503

508504
temporary_variables: Mapping[str, lp.TemporaryVariable] = {
509505
"iel_lbound": lp.TemporaryVariable(

‎arraycontext/impl/numpy/fake_numpy.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,11 @@ def vdot(self, a, b):
239239

240240
def any(self, a, /):
241241
return rec_map_reduce_array_container(partial(reduce, np.logical_or),
242-
lambda subary: np.any(subary), a)
242+
np.any, a)
243243

244244
def all(self, a, /):
245245
return rec_map_reduce_array_container(partial(reduce, np.logical_and),
246-
lambda subary: np.all(subary), a)
246+
np.all, a)
247247

248248
@override
249249
def array_equal(self,

‎arraycontext/impl/pyopencl/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def __init__(self,
152152
super().__init__()
153153
self.context = queue.context
154154
self.queue = queue
155-
self.allocator = allocator if allocator else None
155+
self.allocator = allocator or None
156156
if wait_event_queue_length is None:
157157
wait_event_queue_length = 10
158158

‎arraycontext/impl/pyopencl/fake_numpy.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def sum(self,
365365
dtype: DTypeLike | None = None,
366366
) -> ArrayOrScalar:
367367
if isinstance(axis, int):
368-
axis = axis,
368+
axis = (axis,)
369369

370370
def _rec_sum(ary):
371371
if axis not in [None, tuple(range(ary.ndim))]:
@@ -400,7 +400,7 @@ def max(self,
400400
queue = self._array_context.queue
401401

402402
if isinstance(axis, int):
403-
axis = axis,
403+
axis = (axis,)
404404

405405
def _rec_max(ary):
406406
if axis not in [None, tuple(range(ary.ndim))]:
@@ -438,7 +438,7 @@ def min(self,
438438
queue = self._array_context.queue
439439

440440
if isinstance(axis, int):
441-
axis = axis,
441+
axis = (axis,)
442442

443443
def _rec_min(ary):
444444
if axis not in [None, tuple(range(ary.ndim))]:

‎arraycontext/impl/pytato/compile.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def id_collector(keys, ary):
173173
def _to_input_for_compiled(
174174
ary: AllowedArrayTc,
175175
actx: _BasePytatoArrayContext) -> AllowedArrayTc:
176-
"""
176+
r"""
177177
Preprocess *ary* before turning it into a :class:`pytato.array.Placeholder`
178178
in :meth:`LazilyCompilingFunctionCaller.__call__`.
179179

‎arraycontext/impl/pytato/fake_numpy.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ def stack(self, arrays, axis=0):
175175
def all(self, a, /):
176176
return rec_map_reduce_array_container(
177177
partial(reduce, pt.logical_and),
178-
lambda subary: pt.all(subary), a)
178+
pt.all, a)
179179

180180
def any(self, a, /):
181181
return rec_map_reduce_array_container(
182182
partial(reduce, pt.logical_or),
183-
lambda subary: pt.any(subary), a)
183+
pt.any, a)
184184

185185
@override
186186
def array_equal(self,

‎arraycontext/pytest.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def inner(metafunc: pytest.Metafunc) -> None:
421421
arg_value_tuples = sorted([
422422
tuple(arg_dict[name] for name in arg_names)
423423
for arg_dict in arg_values_with_actx
424-
], key=lambda x: str(x))
424+
], key=str)
425425

426426
metafunc.parametrize(arg_names, arg_value_tuples, ids=ids)
427427

0 commit comments

Comments
 (0)