Skip to content

Commit db0f33f

Browse files
committed
bump: v0.25.1, update docs
1 parent 7cc162b commit db0f33f

File tree

6 files changed

+81
-38
lines changed

6 files changed

+81
-38
lines changed

CHANGELOG.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9-
## [0.25.0] - 2025-02-25
9+
## [0.25.1] - 2025-02-28
1010
### Added:
1111
- Tree Exporter: `vprint_tree` to have same arguments as `vyield_tree`, add more test cases.
1212
- Tree Exporter: `hprint_tree` to support multiline node name, alias, and border style.
@@ -741,7 +741,8 @@ ignore null attribute columns.
741741
- Utility Iterator: Tree traversal methods.
742742
- Workflow To Do App: Tree use case with to-do list implementation.
743743

744-
[Unreleased]: https://github.com/kayjan/bigtree/compare/0.25.0...HEAD
744+
[Unreleased]: https://github.com/kayjan/bigtree/compare/0.25.1...HEAD
745+
[0.25.1]: https://github.com/kayjan/bigtree/compare/0.25.0...0.25.1
745746
[0.25.0]: https://github.com/kayjan/bigtree/compare/0.24.0...0.25.0
746747
[0.24.0]: https://github.com/kayjan/bigtree/compare/0.23.1...0.24.0
747748
[0.23.1]: https://github.com/kayjan/bigtree/compare/0.23.0...0.23.1

bigtree/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.25.0"
1+
__version__ = "0.25.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/export/stdout.py

+54-27
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,19 @@ def hprint_tree(
495495
- a -+ \\- e
496496
\\- c
497497
498+
**Border**
499+
500+
>>> hprint_tree(root, style="rounded", border_style="rounded")
501+
╭───────╮
502+
╭───────╮╭┤ d │
503+
╭┤ b ├┤╰───────╯
504+
╭───────╮│╰───────╯│╭───────╮
505+
│ a ├┤ ╰┤ e │
506+
╰───────╯│ ╰───────╯
507+
│╭───────╮
508+
╰┤ c │
509+
╰───────╯
510+
498511
**Printing to a file**
499512
>>> import io
500513
>>> output = io.StringIO()
@@ -537,7 +550,7 @@ def hyield_tree(
537550
max_depth: int = 0,
538551
intermediate_node_name: bool = True,
539552
style: Union[str, Iterable[str], constants.BaseHPrintStyle] = "const",
540-
border_style: Optional[Union[str, Iterable[str], constants.BorderStyle]] = "const",
553+
border_style: Optional[Union[str, Iterable[str], constants.BorderStyle]] = None,
541554
strip: bool = True,
542555
) -> List[str]:
543556
"""Yield tree in horizontal orientation to console, starting from `tree`.
@@ -642,6 +655,20 @@ def hyield_tree(
642655
- a -+ \\- e
643656
\\- c
644657
658+
**Border**
659+
660+
>>> result = hyield_tree(root, style="rounded", border_style="rounded")
661+
>>> print("\\n".join(result))
662+
╭───────╮
663+
╭───────╮╭┤ d │
664+
╭┤ b ├┤╰───────╯
665+
╭───────╮│╰───────╯│╭───────╮
666+
│ a ├┤ ╰┤ e │
667+
╰───────╯│ ╰───────╯
668+
│╭───────╮
669+
╰┤ c │
670+
╰───────╯
671+
645672
Args:
646673
tree (Node): tree to print
647674
alias (str): node attribute to use for node name in tree as alias to `node_name`, if present.
@@ -976,19 +1003,19 @@ def vprint_tree(
9761003
9771004
**Custom Styles**
9781005
979-
>>> from bigtree import ANSIVPrintStyle, ANSIBorderStyle
980-
>>> vprint_tree(root, style=ANSIVPrintStyle, border_style=ANSIBorderStyle, strip=True)
981-
`---`
982-
| a |
983-
`-+-`
984-
/----+-----\\
985-
`-+-` `-+-`
986-
| b | | c |
987-
`-+-` `---`
988-
/--+---\\
989-
`-+-` `-+-`
990-
| d | | e |
991-
`---` `---`
1006+
>>> from bigtree import RoundedVPrintStyle, RoundedBorderStyle
1007+
>>> vprint_tree(root, style=RoundedVPrintStyle, border_style=RoundedBorderStyle, strip=True)
1008+
╭───╮
1009+
a
1010+
╰─┬─╯
1011+
╭────┴─────╮
1012+
╭─┴─╮ ╭─┴─╮
1013+
b c
1014+
╰─┬─╯ ╰───╯
1015+
╭──┴───╮
1016+
╭─┴─╮ ╭─┴─╮
1017+
d │ │ e
1018+
╰───╯ ╰───╯
9921019
9931020
**Printing to a file**
9941021
>>> import io
@@ -1207,20 +1234,20 @@ def vyield_tree(
12071234
12081235
**Custom Styles**
12091236
1210-
>>> from bigtree import ANSIVPrintStyle, ANSIBorderStyle
1211-
>>> result = vyield_tree(root, style=ANSIVPrintStyle, border_style=ANSIBorderStyle, strip=True)
1237+
>>> from bigtree import RoundedVPrintStyle, RoundedBorderStyle
1238+
>>> result = vyield_tree(root, style=RoundedVPrintStyle, border_style=RoundedBorderStyle, strip=True)
12121239
>>> print("\\n".join(result))
1213-
`---`
1214-
| a |
1215-
`-+-`
1216-
/----+-----\\
1217-
`-+-` `-+-`
1218-
| b | | c |
1219-
`-+-` `---`
1220-
/--+---\\
1221-
`-+-` `-+-`
1222-
| d | | e |
1223-
`---` `---`
1240+
╭───╮
1241+
a
1242+
╰─┬─╯
1243+
╭────┴─────╮
1244+
╭─┴─╮ ╭─┴─╮
1245+
b c
1246+
╰─┬─╯ ╰───╯
1247+
╭──┴───╮
1248+
╭─┴─╮ ╭─┴─╮
1249+
d │ │ e
1250+
╰───╯ ╰───╯
12241251
12251252
Args:
12261253
tree (Node): tree to print

docs/bigtree/tree/export.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ While exporting to another data type, methods can take in arguments to determine
2828
|------------------------|-------------------------------------|-----------------------|------------|---------------------------------------|-------------------------------------------------------|
2929
| `print_tree` | Yes with `attr_list` or `all_attrs` | Yes | No | No | Tree style |
3030
| `yield_tree` | No, returns node | Yes | No | No | Tree style |
31-
| `hprint_tree` | No | Yes | No | Yes, by hiding intermediate node name | Tree style |
32-
| `hyield_tree` | No | Yes | No | Yes, by hiding intermediate node name | Tree style |
31+
| `hprint_tree` | No | Yes | No | Yes, by hiding intermediate node name | Tree style, border style |
32+
| `hyield_tree` | No | Yes | No | Yes, by hiding intermediate node name | Tree style, border style |
3333
| `vprint_tree` | No | Yes | No | Yes, by hiding intermediate node name | Tree style, border style |
3434
| `vyield_tree` | No | Yes | No | Yes, by hiding intermediate node name | Tree style, border style |
3535
| `tree_to_newick` | Yes with `attr_list` | No | No | Yes, by hiding intermediate node name | Length separator and attribute prefix and separator |

docs/gettingstarted/demo/tree.md

+20-5
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,12 @@ Construct nodes with attributes. *DataFrame* can contain either <mark>path colum
339339

340340
### 1. Print Tree
341341

342-
After tree is constructed, it can be viewed by printing to console using `show` or `hshow` method directly,
343-
for vertical and horizontal orientation respectively.
344-
Alternatively, the `print_tree` or `hprint_tree` method can be used.
342+
After tree is constructed, it can be viewed by printing to console using `show`, `hshow`, or `vshow` method directly,
343+
for compact, horizontal, and vertical orientation respectively.
344+
Alternatively, the `print_tree`, `hprint_tree`, or `vprint_tree` method can be used.
345345

346346
```python hl_lines="8 15"
347-
from bigtree import Node, print_tree, hprint_tree
347+
from bigtree import Node, print_tree, hprint_tree, vprint_tree
348348

349349
root = Node("a", alias="alias-a", age=90, gender="F")
350350
b = Node("b", age=65, gender="M", parent=root)
@@ -363,17 +363,31 @@ hprint_tree(root) # (2)!
363363
# ┌─ b ─┤
364364
# ─ a ─┤ └─ e
365365
# └─ c
366+
367+
vprint_tree(root) # (3)!
368+
# ┌───┐
369+
# │ a │
370+
# └─┬─┘
371+
# ┌────┴─────┐
372+
# ┌─┴─┐ ┌─┴─┐
373+
# │ b │ │ c │
374+
# └─┬─┘ └───┘
375+
# ┌──┴───┐
376+
# ┌─┴─┐ ┌─┴─┐
377+
# │ d │ │ e │
378+
# └───┘ └───┘
366379
```
367380

368381
1. Alternatively, `root.show()` can be used
369382
2. Alternatively, `root.hshow()` can be used
383+
3. Alternatively, `root.vshow()` can be used
370384

371385
Other customizations for printing are also available, such as:
372386

373387
- Printing alias instead of node name, if present
374388
- Printing subtree
375389
- Printing tree with attributes
376-
- Different built-in or custom style
390+
- Different built-in or custom style and border style
377391

378392
=== "Alias"
379393
```python hl_lines="1"
@@ -572,6 +586,7 @@ Below is the table of operations available to `BaseNode` and `Node` classes.
572586
|-------------------------------------------------|------------------------------------------------------------|--------------------------------------------|
573587
| Visualize tree (only for `Node`) | `root.show()` | None |
574588
| Visualize tree (horizontally) (only for `Node`) | `root.hshow()` | None |
589+
| Visualize tree (vertically) (only for `Node`) | `root.vshow()` | None |
575590
| Get node information | `root.describe(exclude_prefix="_")` | [('name', 'a')] |
576591
| Find path from one node to another | `root.go_to(node_e)` | [Node(/a, ), Node(/a/b, ), Node(/a/b/e, )] |
577592
| Add child to node | `root.append(Node("j"))` | None |

docs/home/tree.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ For **Tree** implementation, there are 9 main components.
5353
- Plot tree using matplotlib (optional dependency)
5454

5555
## [**🔨 Exporting Tree**](../bigtree/tree/export.md)
56-
- Print to console, in vertical or horizontal orientation
56+
- Print to console, in compact, vertical, or horizontal orientation
5757
- Export to *Newick string notation*, *dictionary*, *nested dictionary*, *pandas DataFrame*, or *polars DataFrame*
5858
- Export tree to *dot* (can save to .dot, .png, .svg, .jpeg files)
5959
- Export tree to *Pillow* (can save to .png, .jpg)

0 commit comments

Comments
 (0)