diff --git a/arraycontext/container/arithmetic.py b/arraycontext/container/arithmetic.py index b085a7dc22cac7d26bfa24b9039aea8e49d19234..66e10ff022263e571ebb6a55bbeeeb21cf884655 100644 --- a/arraycontext/container/arithmetic.py +++ b/arraycontext/container/arithmetic.py @@ -413,9 +413,8 @@ def with_container_arithmetic( for i, bct in enumerate(bcast_container_types): gen(f"from {bct.__module__} import {bct.__qualname__} as _bctype{i}") gen("") - outer_bcast_type_names = tuple([ - f"_bctype{i}" for i in range(len(bcast_container_types)) - ]) + outer_bcast_type_names = tuple( + f"_bctype{i}" for i in range(len(bcast_container_types))) if bcast_number: outer_bcast_type_names += ("Number",) diff --git a/arraycontext/context.py b/arraycontext/context.py index 3ccc357cf699e0b13faddedf8aafea5a7ca1fe91..d296f8f7dd276d80e678fea99cfbf27b71f755af 100644 --- a/arraycontext/context.py +++ b/arraycontext/context.py @@ -475,7 +475,7 @@ class ArrayContext(ABC): :return: the output of the einsum :mod:`loopy` program """ if arg_names is None: - arg_names = tuple([f"arg{i}" for i in range(len(args))]) + arg_names = tuple(f"arg{i}" for i in range(len(args))) prg = self._get_einsum_prg(spec, arg_names, tagged) out_ary = self.call_loopy( diff --git a/arraycontext/impl/pytato/compile.py b/arraycontext/impl/pytato/compile.py index 523ef3a4eb24dae62f52160f5f767427d2f79878..54d2cbb8f1979f9f2ca46604191a8ecf5f9996e8 100644 --- a/arraycontext/impl/pytato/compile.py +++ b/arraycontext/impl/pytato/compile.py @@ -214,10 +214,10 @@ def _get_f_placeholder_args(arg, kw, arg_id_to_name, actx): :attr:`BaseLazilyCompilingFunctionCaller.f`. """ if np.isscalar(arg): - name = arg_id_to_name[(kw,)] + name = arg_id_to_name[kw,] return pt.make_placeholder(name, (), np.dtype(type(arg))) elif isinstance(arg, pt.Array): - name = arg_id_to_name[(kw,)] + name = arg_id_to_name[kw,] # Transform the DAG to give metadata inference a chance to do its job arg = _to_input_for_compiled(arg, actx) return pt.make_placeholder(name, arg.shape, arg.dtype, @@ -225,7 +225,8 @@ def _get_f_placeholder_args(arg, kw, arg_id_to_name, actx): tags=arg.tags) elif is_array_container_type(arg.__class__): def _rec_to_placeholder(keys, ary): - name = arg_id_to_name[(kw, *keys)] + index = (kw, *keys) + name = arg_id_to_name[index] # Transform the DAG to give metadata inference a chance to do its job ary = _to_input_for_compiled(ary, actx) return pt.make_placeholder(name, diff --git a/arraycontext/pytest.py b/arraycontext/pytest.py index e74a6aef2041c626f77b69c10e772c78ee77e2f2..088c7e3e413d7add22369a2788ca21640b472c3f 100644 --- a/arraycontext/pytest.py +++ b/arraycontext/pytest.py @@ -396,7 +396,7 @@ def pytest_generate_tests_for_array_contexts( # NOTE: sorts the args so that parallel pytest works arg_value_tuples = sorted([ - tuple([arg_dict[name] for name in arg_names]) + tuple(arg_dict[name] for name in arg_names) for arg_dict in arg_values_with_actx ], key=lambda x: str(x)) diff --git a/arraycontext/version.py b/arraycontext/version.py index a1da82c1f4244fe0daf3e99d52fe7650e6c5a56e..31baea0595e686ea13700917b2a5ad4e20b2bf4e 100644 --- a/arraycontext/version.py +++ b/arraycontext/version.py @@ -8,7 +8,7 @@ def _parse_version(version: str) -> Tuple[Tuple[int, ...], str]: m = re.match("^([0-9.]+)([a-z0-9]*?)$", VERSION_TEXT) assert m is not None - return tuple([int(nr) for nr in m.group(1).split(".")]), m.group(2) + return tuple(int(nr) for nr in m.group(1).split(".")), m.group(2) VERSION_TEXT = metadata.version("arraycontext") diff --git a/test/test_arraycontext.py b/test/test_arraycontext.py index 63387dbebd40214cc6353d1c1eff6234a221b1fd..107539b42c099cfaa2e4aaa12ae681f252087502 100644 --- a/test/test_arraycontext.py +++ b/test/test_arraycontext.py @@ -170,11 +170,11 @@ class DOFArray: @property def real(self): - return DOFArray(self.array_context, tuple([subary.real for subary in self])) + return DOFArray(self.array_context, tuple(subary.real for subary in self)) @property def imag(self): - return DOFArray(self.array_context, tuple([subary.imag for subary in self])) + return DOFArray(self.array_context, tuple(subary.imag for subary in self)) @serialize_container.register(DOFArray) @@ -258,9 +258,8 @@ def _get_test_containers(actx, ambient_dim=2, shapes=50_000): if isinstance(shapes, (Number, tuple)): shapes = [shapes] - x = DOFArray(actx, tuple([ - actx.from_numpy(randn(shape, np.float64)) - for shape in shapes])) + x = DOFArray(actx, tuple(actx.from_numpy(randn(shape, np.float64)) + for shape in shapes)) # pylint: disable=unexpected-keyword-arg, no-value-for-parameter dataclass_of_dofs = MyContainer( @@ -1081,13 +1080,11 @@ def test_flatten_array_container(actx_factory, shapes): if isinstance(shapes, (int, tuple)): shapes = [shapes] - ary = DOFArray(actx, tuple([ - actx.from_numpy(randn(shape, np.float64)) - for shape in shapes])) + ary = DOFArray(actx, tuple(actx.from_numpy(randn(shape, np.float64)) + for shape in shapes)) - template = DOFArray(actx, tuple([ - actx.from_numpy(randn(shape, np.complex128)) - for shape in shapes])) + template = DOFArray(actx, tuple(actx.from_numpy(randn(shape, np.complex128)) + for shape in shapes)) flat = flatten(ary, actx) ary_roundtrip = unflatten(template, flat, actx, strict=False)