From 104937c97c0f42dcf14d7ae9ff5ab363553be0b8 Mon Sep 17 00:00:00 2001 From: Alexandru Fikl Date: Sun, 11 Aug 2024 16:10:30 +0300 Subject: [PATCH] ruff: fix C409 rule issues --- contrib/fortran-to-opencl/translate.py | 2 +- pyopencl/array.py | 7 ++++--- test/test_enqueue_copy.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/contrib/fortran-to-opencl/translate.py b/contrib/fortran-to-opencl/translate.py index 27b705517..1d144b01d 100644 --- a/contrib/fortran-to-opencl/translate.py +++ b/contrib/fortran-to-opencl/translate.py @@ -1096,7 +1096,7 @@ def map_Equivalence(self, node): def dtype_from_stmt(self, stmt): length, kind = stmt.selector assert not kind - return np.dtype(self.TYPE_MAP[(type(stmt).__name__.lower(), length)]) + return np.dtype(self.TYPE_MAP[type(stmt).__name__.lower(), length]) def map_type_decl(self, node): scope = self.scope_stack[-1] diff --git a/pyopencl/array.py b/pyopencl/array.py index 98ef986c3..b6f52abe2 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -2050,9 +2050,10 @@ def squeeze(self): .. versionadded:: 2015.2 """ - new_shape = tuple([dim for dim in self.shape if dim > 1]) - new_strides = tuple([self.strides[i] - for i, dim in enumerate(self.shape) if dim > 1]) + new_shape = tuple(dim for dim in self.shape if dim > 1) + new_strides = tuple( + self.strides[i] for i, dim in enumerate(self.shape) + if dim > 1) return self._new_with_changes( self.base_data, self.offset, diff --git a/test/test_enqueue_copy.py b/test/test_enqueue_copy.py index d1aa4f388..91ed0ddfd 100644 --- a/test/test_enqueue_copy.py +++ b/test/test_enqueue_copy.py @@ -33,7 +33,7 @@ def generate_slice(start, shape): - return tuple([slice(start[i], start[i]+shape[i]) for i in range(len(start))]) + return tuple(slice(start[i], start[i]+shape[i]) for i in range(len(start))) def test_enqueue_copy_rect_2d(ctx_factory, honor_skip=True):