Skip to content
This repository has been archived by the owner on Feb 11, 2025. It is now read-only.

experiment ui wrapper prototype #15

Merged
merged 8 commits into from
Sep 24, 2024
Merged

experiment ui wrapper prototype #15

merged 8 commits into from
Sep 24, 2024

Conversation

jashlu
Copy link
Collaborator

@jashlu jashlu commented Sep 5, 2024

Walkthrough of the UI simulation

@jashlu jashlu requested review from hollandjg and zzaydin September 5, 2024 16:28
@jashlu
Copy link
Collaborator Author

jashlu commented Sep 5, 2024

Untitled.mov

Copy link
Member

@hollandjg hollandjg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Josh, this looks great! It's so close to being a complete prototype now!
Since it's so complete, I've got some thorough feedback for you. Good work!

src/social_norms_trees/mutate_tree.py Outdated Show resolved Hide resolved
Comment on lines 147 to 187
def format_tree_with_indices(tree: py_trees.behaviour.Behaviour, mode: str = "all") -> str:
"""
Examples:
>>> print(format_tree_with_indices(py_trees.behaviours.Dummy()))
0: --> Dummy

>>> tree = py_trees.composites.Sequence("s1", False, children=[
... py_trees.behaviours.Dummy(),
... py_trees.behaviours.Success(),
... py_trees.composites.Sequence("s2", False, children=[
... py_trees.behaviours.Dummy(),
... ]),
... py_trees.composites.Sequence("", False, children=[
... py_trees.behaviours.Failure(),
... py_trees.behaviours.Periodic("p", n=1),
... ]),
... ])
>>> print(format_tree_with_indices(tree)) # doctest: +NORMALIZE_WHITESPACE
0: [-] s1
1: --> Dummy
2: --> Success
3: [-] s2
4: --> Dummy
5: [-]
6: --> Failure
7: --> p

"""
index_strings = []
index = 0
for i, node in enumerate_nodes(tree):
if mode == "children" and node.children:
# Do not number parent nodes in 'children' mode
index_strings.append('_')
elif mode == "parents" and not node.children:
# Do not number child nodes in 'parents' mode
index_strings.append('_')
else:
# Number all nodes in 'all' mode
index_strings.append(str(index))
index += 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to see some tests of this – you can copy and modify the existing doctest to show how to use the mode switch.

src/social_norms_trees/ui_wrapper.py Outdated Show resolved Hide resolved


def load_db():
if os.path.exists(DB_FILE):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if someone wants to load a file and puts in the argument with the name, but it doesn't exist? I'd expect there to be an error "IOError: File Doesn't Exist" or something like that, but this will fail quietly.

How about we make this just throw the error if you give it a file name which doesn't exist, and if you don't give it a file name then it returns the empty dictionary?

src/social_norms_trees/ui_wrapper.py Show resolved Hide resolved
src/social_norms_trees/ui_wrapper.py Outdated Show resolved Hide resolved
src/social_norms_trees/ui_wrapper.py Outdated Show resolved Hide resolved
src/social_norms_trees/ui_wrapper.py Outdated Show resolved Hide resolved
src/social_norms_trees/ui_wrapper.py Show resolved Hide resolved
src/social_norms_trees/ui_wrapper.py Outdated Show resolved Hide resolved
@hollandjg hollandjg merged commit 7ae2b11 into main Sep 24, 2024
8 checks passed
@hollandjg hollandjg deleted the ui-wrapper branch September 24, 2024 13:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants