-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
Untitled.mov |
There was a problem hiding this 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!
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 |
There was a problem hiding this comment.
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
|
||
|
||
def load_db(): | ||
if os.path.exists(DB_FILE): |
There was a problem hiding this comment.
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?
Co-authored-by: John Gerrard Holland <john_holland1@brown.edu>
Walkthrough of the UI simulation