Loading ale/transformation.py +5 −2 Original line number Diff line number Diff line Loading @@ -41,10 +41,13 @@ class FrameNode(): self.children = [] self.id = id if parent is not None: self._parent = parent self.parent = parent if rotation is not None: self.rotation = rotation def __repr__(self): return f'ID:{self.id}\nChildren:{self.children}' def __del__(self): """ Custom deletor for a FrameNode. The child node is always responsible Loading Loading @@ -72,7 +75,7 @@ class FrameNode(): of the old parent and adds it to the children of the new parent. """ if self.parent is not None: self.parent.children.remove(self) self._parent.children.remove(self) new_parent.children.append(self) self._parent = new_parent Loading tests/pytests/test_transformation.py +10 −2 Original line number Diff line number Diff line Loading @@ -4,8 +4,8 @@ import numpy as np from ale.rotation import ConstantRotation from ale.transformation import FrameNode @pytest.fixture def frame_tree(): @pytest.fixture(scope='function') def frame_tree(request): """ Test frame tree structure: Loading Loading @@ -34,6 +34,14 @@ def frame_tree(): ] return (nodes, rotations) def test_del_node(frame_tree): nodes, _ = frame_tree node3 = nodes[3] node2 = nodes[2] del node3 assert len(node2.children) == 0 def test_parent_nodes(frame_tree): nodes, _ = frame_tree root_parents = nodes[0].parent_nodes() Loading Loading
ale/transformation.py +5 −2 Original line number Diff line number Diff line Loading @@ -41,10 +41,13 @@ class FrameNode(): self.children = [] self.id = id if parent is not None: self._parent = parent self.parent = parent if rotation is not None: self.rotation = rotation def __repr__(self): return f'ID:{self.id}\nChildren:{self.children}' def __del__(self): """ Custom deletor for a FrameNode. The child node is always responsible Loading Loading @@ -72,7 +75,7 @@ class FrameNode(): of the old parent and adds it to the children of the new parent. """ if self.parent is not None: self.parent.children.remove(self) self._parent.children.remove(self) new_parent.children.append(self) self._parent = new_parent Loading
tests/pytests/test_transformation.py +10 −2 Original line number Diff line number Diff line Loading @@ -4,8 +4,8 @@ import numpy as np from ale.rotation import ConstantRotation from ale.transformation import FrameNode @pytest.fixture def frame_tree(): @pytest.fixture(scope='function') def frame_tree(request): """ Test frame tree structure: Loading Loading @@ -34,6 +34,14 @@ def frame_tree(): ] return (nodes, rotations) def test_del_node(frame_tree): nodes, _ = frame_tree node3 = nodes[3] node2 = nodes[2] del node3 assert len(node2.children) == 0 def test_parent_nodes(frame_tree): nodes, _ = frame_tree root_parents = nodes[0].parent_nodes() Loading