Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix instances of RUF052,RUF051 #896

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading