Skip to content

Commit 0d1b5bc

Browse files
committed
Tree.replace_node: tweak interface
1 parent ea057fe commit 0d1b5bc

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

loopy/schedule/tree.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,15 @@ def add_node(self, node: NodeT, parent: NodeT) -> "Tree[NodeT]":
154154
.set(node, ())),
155155
self._child_to_parent.set(node, parent))
156156

157-
def replace_node(self, node: NodeT, new_id: NodeT) -> "Tree[NodeT]":
157+
def replace_node(self, node: NodeT, new_node: NodeT) -> "Tree[NodeT]":
158158
"""
159-
Returns a copy of *self* with *node* replaced with *new_id*.
159+
Returns a copy of *self* with *node* replaced with *new_node*.
160160
"""
161-
if not self.is_a_node(node):
161+
if node not in self:
162162
raise ValueError(f"'{node}' not present in tree.")
163163

164-
if self.is_a_node(new_id):
165-
raise ValueError(f"cannot rename to '{new_id}', as its already a part"
164+
if new_node in self:
165+
raise ValueError(f"cannot replace with '{new_node}', as its already a part"
166166
" of the tree.")
167167

168168
parent = self.parent(node)

0 commit comments

Comments
 (0)