Skip to content

Commit

Permalink
Merge pull request #87 from kayjan/v0.12.2
Browse files Browse the repository at this point in the history
V0.12.2
  • Loading branch information
Kay Jan authored Sep 11, 2023
2 parents 075565c + 1ea0da6 commit 310de37
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.12.2] - 2023-09-12
### Changed
- Tree Plot: Reingold Tilford Algorithm code for succinctness and docstring.

## [0.12.1] - 2023-09-11
### Fixed
- Tree Plot: Reingold Tilford Algorithm to handle cases of negative x-coordinates with adjustment parameter.
Expand Down Expand Up @@ -314,6 +318,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Utility Iterator: Tree traversal methods.
- Workflow To Do App: Tree use case with to-do list implementation.

[0.12.2]: https://github.com/kayjan/bigtree/compare/0.12.1...0.12.2
[0.12.1]: https://github.com/kayjan/bigtree/compare/0.12.0...0.12.1
[0.12.0]: https://github.com/kayjan/bigtree/compare/0.11.0...0.12.0
[0.11.0]: https://github.com/kayjan/bigtree/compare/0.10.3...0.11.0
Expand Down
2 changes: 1 addition & 1 deletion bigtree/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.12.1"
__version__ = "0.12.2"

from bigtree.binarytree.construct import list_to_binarytree
from bigtree.dag.construct import dataframe_to_dag, dict_to_dag, list_to_dag
Expand Down
28 changes: 7 additions & 21 deletions bigtree/utils/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def first_pass(
descendant of any left sibling at every subsequent level. Intersection happens when the subtrees are not
at least `subtree distance` apart.
If there are any intersection, shift the whole subtree by a new `shift` value, shift any left sibling by a
If there are any intersections, shift the whole subtree by a new `shift` value, shift any left sibling by a
fraction of `shift` value, and shift any right sibling by `shift` + a multiple of the fraction of
`shift` value to keep nodes centralized at the level.
Expand Down Expand Up @@ -166,25 +166,11 @@ def first_pass(
),
)

# Shift the nodes between leftmost subtree and right_node
for multiple, left_sibling in enumerate(
parent_node.children[:tree_node_idx]
):
left_sibling.set_attrs(
# Shift siblings (left siblings, itself, right siblings) accordingly
for multiple, sibling in enumerate(parent_node.children):
sibling.set_attrs(
{
"shift": left_sibling.get_attr("shift")
+ (_shift * multiple / tree_node_idx)
}
)

# Shift right_node itself and the nodes to the right of right_node
for multiple, right_sibling in enumerate(
parent_node.children[tree_node_idx:]
):
right_sibling.set_attrs(
{
"shift": right_sibling.get_attr("shift", 0)
+ _shift
"shift": sibling.get_attr("shift", 0)
+ (_shift * multiple / tree_node_idx)
}
)
Expand Down Expand Up @@ -298,7 +284,7 @@ def second_pass(
x_adjustment: Optional[float] = 0.0,
) -> float:
"""
Performs pre-order traversal of tree and determine the final `x` and `y` values for each node.
Performs pre-order traversal of tree and determines the final `x` and `y` values for each node.
Modifies tree in-place.
Notation:
Expand Down Expand Up @@ -352,7 +338,7 @@ def second_pass(


def third_pass(tree_node: BaseNode, x_adjustment: float) -> None:
"""Adjust all x-coordinates by an adjustment value so that every x-coordinate is greater than 0.
"""Adjust all x-coordinates by an adjustment value so that every x-coordinate is greater than or equal to 0.
Modifies tree in-place.
Args:
Expand Down

0 comments on commit 310de37

Please sign in to comment.