Skip to content

Commit

Permalink
Fix instances of RUF052,RUF051
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Dec 15, 2024
1 parent f2ed9db commit 7b7e9f8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
16 changes: 8 additions & 8 deletions loopy/schedule/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions loopy/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions loopy/transform/precompute.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down

0 comments on commit 7b7e9f8

Please sign in to comment.