From 6e0773efd19fddd3a2753a5a1b0343685ccef2f2 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sat, 14 Dec 2024 22:38:11 -0600 Subject: [PATCH] Fix instances of RUF052,RUF051 --- loopy/schedule/tree.py | 16 ++++++++-------- loopy/tools.py | 4 ++-- loopy/transform/precompute.py | 3 +-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/loopy/schedule/tree.py b/loopy/schedule/tree.py index cc580713c..3861aa75c 100644 --- a/loopy/schedule/tree.py +++ b/loopy/schedule/tree.py @@ -149,11 +149,11 @@ def add_node(self, node: NodeT, parent: NodeT) -> Tree[NodeT]: siblings = self._parent_to_children[parent] - _parent_to_children_mut = self._parent_to_children.mutate() - _parent_to_children_mut[parent] = (*siblings, node) - _parent_to_children_mut[node] = () + parent_to_children_mut = self._parent_to_children.mutate() + parent_to_children_mut[parent] = (*siblings, node) + parent_to_children_mut[node] = () - return Tree(_parent_to_children_mut.finish(), + return Tree(parent_to_children_mut.finish(), self._child_to_parent.set(node, parent)) def replace_node(self, node: NodeT, new_node: NodeT) -> Tree[NodeT]: @@ -223,11 +223,11 @@ def move_node(self, node: NodeT, new_parent: NodeT | None) -> Tree[NodeT]: parents_new_children = tuple(frozenset(siblings) - frozenset([node])) new_parents_children = (*self.children(new_parent), node) - _parent_to_children_mut = self._parent_to_children.mutate() - _parent_to_children_mut[parent] = parents_new_children - _parent_to_children_mut[new_parent] = new_parents_children + parent_to_children_mut = self._parent_to_children.mutate() + parent_to_children_mut[parent] = parents_new_children + parent_to_children_mut[new_parent] = new_parents_children - return Tree(_parent_to_children_mut.finish(), + return Tree(parent_to_children_mut.finish(), self._child_to_parent.set(node, new_parent)) def __str__(self) -> str: diff --git a/loopy/tools.py b/loopy/tools.py index 20904a3e4..31c9176d9 100644 --- a/loopy/tools.py +++ b/loopy/tools.py @@ -305,10 +305,10 @@ def empty_aligned(shape, dtype, order="C", n=64): # We now need to know how to offset base_ary # so it is correctly aligned - _array_aligned_offset = (n-address_from_numpy(base_ary)) % n + array_aligned_offset = (n-address_from_numpy(base_ary)) % n array = np.frombuffer( - base_ary[_array_aligned_offset:_array_aligned_offset-n].data, + base_ary[array_aligned_offset:array_aligned_offset-n].data, dtype=dtype).reshape(shape, order=order) return array diff --git a/loopy/transform/precompute.py b/loopy/transform/precompute.py index 831d0c360..904d27d2d 100644 --- a/loopy/transform/precompute.py +++ b/loopy/transform/precompute.py @@ -772,8 +772,7 @@ def precompute_for_single_kernel( if abm.non1_storage_axis_flags[i]: non1_storage_axis_names.append(saxis) else: - if saxis in new_iname_to_tag: - del new_iname_to_tag[saxis] + new_iname_to_tag.pop(saxis, None) if saxis in preexisting_precompute_inames: raise LoopyError("precompute axis %d (1-based) was "