Use Unicode-art for the tree display.#83
Draft
ezio-melotti wants to merge 1 commit into
Draft
Conversation
ezio-melotti
marked this pull request as draft
August 4, 2022 00:32
Owner
|
I prefer #4
…On 8/3/22 15:37, Ezio Melotti wrote:
This PR is a proof of concept that updates the `Branch.display_viz()` method to use Unicode-art instead of ASCII-art.
This is an example of the new representation:
```
╭────┤+├──────────────────────╮
╭──────────┤+├──────────╮ b
╭────┤+├────╮ ╭────┤+├────╮
b b c a
```
Or as a screenshot from my terminal:

I also played around with a few different representations:
1. without rounded corners and nothing around the operator:
```
┌───────────────────────*─────┐
a ┌─────*─────────────────┐
┌───────────-─────┐ a
b ┌─────-─────┐
a a
```
2. with rounded corners and nothing around the operator:
```
╭─────────/───────────────────╮
╭────*──────────────╮ ╭────+────╮
╭─────────-────╮ c c b
a ╭────/────╮
a c
```
3. with rounded corners and `[ ]` around the operators:
```
╭───[+]───────────────────────╮
╭──────────────────[-]───╮ c
b ╭────────[+]────────╮
╭───[-]───╮ ╭───[-]───╮
b c a c
```
4. with rounded corners and `┤ ├` around the operators (the proposed one, shown at the top).
TODO:
- [ ] decide which representation to adopt
- [ ] fix tests accordingly
- [ ] possibly add a `unicode=True` arg
There are also a few items that don't seem directly related to this PR, but should be fixed in a separate PR:
- [ ] fix some alignment issues
- [ ] handle functions/operators with len > 1
- [ ] handle deep tree
You can view, comment on, or merge this pull request online at:
#83
-- Commit Summary --
* Use Unicode-art for the tree display.
-- File Changes --
M karoo_gp/branch.py (15)
-- Patch Links --
https://github.com/kstaats/karoo_gp/pull/83.patch
https://github.com/kstaats/karoo_gp/pull/83.diff
|
Collaborator
|
I also like Number 4. re: 'deep tree', I thought of adding an option to clip the display at the bottom and/or top, to guarantee readability. There are some details to work out, but here's an idea: Another useful feature would be to highlight one node, or a node + all nodes below it. I'm close to adding |
Collaborator
Author
Owner
|
Keep in mind that with larger datasets we'll employ much larger trees.
This visualization works well for small trees, but when they have 100+
nodes, it will wrap on-screen, no?
…On 8/3/22 19:44, Grant wrote:
I also like Number 4.
re: 'deep tree', I thought of adding an option to clip the display at the bottom and/or top, to guarantee readability. There are some details to work out, but here's an idea:
```
(+3 hidden)
╭────┤+├──────────────────────╮
╭──────────┤+├──────────╮ b
╭────┤+├────╮ ╭────┤+├────╮
b b |+| |-|
(+4 hidden) (+2 hidden)
```
Another useful feature would be to highlight one node, or a node + all nodes below it. I'm close to adding `click` for my work on the interactive mode, which I'm sure we can co-opt for this.
|
Collaborator
Author
|
Yes, this is the last item in the checklist in my first message -- this PR was mostly a proof of concept. |
Collaborator
|
For Karoo 3.0:
Future updates:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


This PR is a proof of concept that updates the
Branch.display_viz()method to use Unicode-art instead of ASCII-art.This is an example of the new representation:
Or as a screenshot from my terminal:

I also played around with a few different representations:
[ ]around the operators:┤ ├around the operators (the proposed one, shown at the top).TODO:
unicode=TrueargThere are also a few items that don't seem directly related to this PR, but should be fixed in a separate PR: