Skip to content

Commit 3e1fb05

Browse files
committed
v0.8.1 fix tree modify method
1 parent dc89864 commit 3e1fb05

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.8.1] - 2023-03-10
8+
### Fixed
9+
- Tree Modify: Fix issue of `sep` of tree differing from the `sep` in `from_paths` and `to_paths`.
10+
711
## [0.8.0] - 2023-03-10
812
### Added
913
- Type Checking: Type checking with `mypy`, added type checks to pre-commit hooks.
@@ -213,6 +217,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
213217
- Utility Iterator: Tree traversal methods.
214218
- Workflow To Do App: Tree use case with to-do list implementation.
215219

220+
[0.8.1]: https://github.com/kayjan/bigtree/compare/v0.8.0...v0.8.1
216221
[0.8.0]: https://github.com/kayjan/bigtree/compare/v0.7.4...v0.8.0
217222
[0.7.4]: https://github.com/kayjan/bigtree/compare/v0.7.3...v0.7.4
218223
[0.7.3]: https://github.com/kayjan/bigtree/compare/v0.7.2...v0.7.3

bigtree/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.8.0"
1+
__version__ = "0.8.1"
22

33
from bigtree.binarytree.construct import list_to_binarytree
44
from bigtree.dag.construct import dataframe_to_dag, dict_to_dag, list_to_dag

bigtree/tree/modify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ def copy_or_shift_logic(
816816
# Create intermediate parent node, if applicable
817817
while (not to_node) & (idx + 1 < len(to_path_list)):
818818
idx += 1
819-
to_path_parent = sep.join(to_path_list[:-idx])
819+
to_path_parent = tree_sep.join(to_path_list[:-idx])
820820
if transfer_indicator:
821821
to_node = find_path(to_tree, to_path_parent) # type: ignore
822822
else:

tests/tree/test_modify.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def test_copy_nodes_create_intermediate_path(self):
156156
copy_nodes(self.root, from_paths, to_paths)
157157
assert self.root.max_depth == 4, "Shift did not create a tree of depth 4"
158158

159+
# sep
159160
def test_copy_nodes_sep_undefined(self):
160161
from_paths = ["\\d", "\\e", "\\g", "\\h", "\\f"]
161162
to_paths = ["a\\b\\d", "a\\b\\e", "a\\b\\e\\g", "a\\b\\e\\h", "a\\c\\f"]
@@ -177,6 +178,25 @@ def test_copy_nodes_sep(self):
177178
assert_tree_structure_basenode_root_attr(self.root)
178179
assert_tree_structure_node_root_generic(self.root)
179180

181+
def test_copy_nodes_sep_different(self):
182+
# Delete intermediate nodes
183+
from_paths = ["\\a\\b", "\\a\\c", "\\a\\e"]
184+
to_paths = [None, None, None]
185+
shift_nodes(self.root, from_paths, to_paths, sep="\\")
186+
187+
# Create intermediate nodes
188+
from_paths = ["\\d", "\\g", "\\h", "\\f"]
189+
to_paths = ["a\\b\\d", "a\\b\\e\\g", "a\\b\\e\\h", "a\\c\\f"]
190+
copy_nodes(self.root, from_paths, to_paths, sep="\\")
191+
192+
# Delete original nodes
193+
from_paths = ["\\a\\d", "\\a\\g", "\\a\\h", "\\a\\f"]
194+
to_paths = [None, None, None, None]
195+
shift_nodes(self.root, from_paths, to_paths, sep="\\")
196+
197+
assert_tree_structure_basenode_root_generic(self.root)
198+
assert_tree_structure_node_root_generic(self.root)
199+
180200
# skippable
181201
def test_copy_nodes_skippable(self):
182202
from_paths = ["i", "d", "e", "g", "h", "f"]

0 commit comments

Comments
 (0)