Skip to content

Commit 2462ae7

Browse files
authored
Merge pull request #107 from kayjan/v0.14.0
V0.14.0
2 parents ba61a3e + b1d7618 commit 2462ae7

File tree

5 files changed

+93
-10
lines changed

5 files changed

+93
-10
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ 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.14.0] - 2023-10-18
8+
### Added
9+
- Tree Modifier: Shift nodes with replacement of to-node with `shift_and_replace_nodes`.
10+
- Tree Modifier: Copy nodes from tree to tree with replacement of to-node with `copy_and_replace_nodes_from_tree_to_tree`.
11+
- Tree Modifier: Any permutation of configuration with replacement of to-node with `replace_logic`.
12+
- Tree Modifier: Add relevant test cases and documentations accordingly.
13+
714
## [0.13.3] - 2023-10-17
815
### Added
916
- Misc: Add automatic release notes with content into GitHub workflow.
@@ -354,6 +361,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
354361
- Utility Iterator: Tree traversal methods.
355362
- Workflow To Do App: Tree use case with to-do list implementation.
356363

364+
[0.14.0]: https://github.com/kayjan/bigtree/compare/0.13.3...0.14.0
357365
[0.13.3]: https://github.com/kayjan/bigtree/compare/0.13.2...0.13.3
358366
[0.13.2]: https://github.com/kayjan/bigtree/compare/0.13.1...0.13.2
359367
[0.13.1]: https://github.com/kayjan/bigtree/compare/0.13.0...0.13.1

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ For **Tree** implementation, there are 9 main components.
4949
1. Shift nodes from location to destination
5050
2. Copy nodes from location to destination
5151
3. Copy nodes from one tree to another
52+
4. Shift and replace nodes from location to destination
53+
5. Copy and replace nodes from one tree to another
5254
5. [**Tree Search**](https://bigtree.readthedocs.io/en/latest/bigtree/tree/search.html)
5355
1. Find multiple nodes based on name, partial path, relative path, attribute value, user-defined condition
5456
2. Find single nodes based on name, partial path, relative path, full path, attribute value, user-defined condition

bigtree/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.13.3"
1+
__version__ = "0.14.0"
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

docs/source/_static/custom.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ blockquote p {
3232
}
3333
ol {
3434
padding-left: 40px;
35+
margin-bottom: 0px;
3536
}
3637
ol p, li p {
3738
margin-bottom: 0;

docs/source/bigtree/tree/modify.rst

Lines changed: 81 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,93 @@
11
|:memo:| Modify
22
===================
33

4-
Shift or copy nodes within same tree or between two trees using
5-
`from_paths` (list of paths) and `to_paths` (list of paths).
4+
There are two types of modification available,
65

7-
There are several configurations available for more customization
6+
1. **Non-replacing scenario**: Shift or copy nodes within same tree or between two trees using `from_paths` (list of paths) and `to_paths` (list of paths).
7+
2. **Replacing scenario**: Shift or copy nodes within same tree or between two trees *while replacing the to-node* using `from_paths` (list of paths) and `to_paths` (list of paths).
88

9-
- `skippable`: Skip shifting/copying of nodes if from_path cannot be found, defaults to False (from node must be found)
10-
- `overriding`: Override existing node if it exists, defaults to False (to node must not exist)
11-
- `merge_children`: Merge children and remove intermediate parent node, defaults to False (children are not merged)
12-
- `merge_leaves`: Merge leaves and remove all intermediate nodes, defaults to False (leaves are not merged)
13-
- `delete_children`: Shift/copy node only and delete its children, defaults to False (nodes are shifted/copied together with children)
9+
In **non-replacing scenario**, there are several configurations available for customization.
1410

15-
.. note:: `merge_children` and `merge_leaves` cannot be simultaneously set to `True`
11+
.. list-table:: Available Configurations for Customization
12+
:widths: 20 40 40
13+
:header-rows: 1
14+
15+
* - Configuration
16+
- Description
17+
- Default Value
18+
* - `copy`
19+
- Indicates whether it is to shift the nodes, or copy the nodes
20+
- False (nodes are shifted, not copied)
21+
* - `to_tree`
22+
- Indicates whether shifting/copying is within the same tree, or between different trees
23+
- None (nodes are shifted/copied within the same tree)
24+
* - `skippable`
25+
- Skip shifting/copying of nodes if from_path cannot be found
26+
- False (from-node must be found)
27+
* - `overriding`
28+
- Override existing node if it exists
29+
- False (to-node must not exist)
30+
* - `merge_children`
31+
- Shift/copy children of from-node and remove intermediate parent node
32+
- False (children are not merged)
33+
* - `merge_leaves`
34+
- Shift/copy leaves of from-node and remove all intermediate nodes
35+
- False (leaves are not merged)
36+
* - `delete_children`
37+
- Shift/copy node only and delete its children
38+
- False (nodes are shifted/copied together with children)
39+
40+
In **replacing scenario**, all the configurations are also available except `overriding`, `merge_children`, and `merge_leaves` as it is doing a one-to-one replacement.
41+
It is by default overriding, and there is nothing to merge.
42+
43+
.. note:: `merge_children` and `merge_leaves` cannot be simultaneously set to `True`.
1644

1745
.. note:: Error will always be thrown if multiple from-nodes are found, paths in `from_paths` must be unique.
1846

47+
Tree Modification Permutations
48+
----------------------------------
49+
50+
There are several ways you can mix and match the tree modification methods.
51+
If you know all the parameters to choose, feel free to use ``copy_or_shift_logic`` or ``replace_logic`` methods as they are the most customizable.
52+
All other methods calls these 2 methods directly.
53+
54+
.. list-table:: Tree Modification Methods
55+
:widths: 10 20 10 20
56+
:header-rows: 1
57+
58+
* - Shift / Copy?
59+
- Same tree / Between two trees?
60+
- Replace destination node?
61+
- Method to use
62+
* - Shift
63+
- Same tree
64+
- No
65+
- ``shift_nodes``
66+
* - Copy
67+
- Same tree
68+
- No
69+
- ``copy_nodes``
70+
* - Copy
71+
- Between two trees
72+
- No
73+
- ``copy_nodes_from_tree_to_tree``
74+
* - Any
75+
- Any
76+
- No
77+
- ``copy_or_shift_logic``
78+
* - Shift
79+
- Same tree
80+
- Yes
81+
- ``shift_and_replace_nodes``
82+
* - Copy
83+
- Between two trees
84+
- Yes
85+
- ``copy_and_replace_nodes_from_tree_to_tree``
86+
* - Any
87+
- Any
88+
- Yes
89+
- ``replace_logic``
90+
1991
Tree Modification Illustration
2092
----------------------------------
2193

0 commit comments

Comments
 (0)