Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: Handle default values consistently #11

Open
MogomotsiFM opened this issue Oct 22, 2024 · 0 comments
Open

Bug fix: Handle default values consistently #11

MogomotsiFM opened this issue Oct 22, 2024 · 0 comments

Comments

@MogomotsiFM
Copy link

The default value for ChildTree is set elsewhere instead of the set_default method. As a result, default values are not handled consistently in the rest of the code. The following two cases demonstrate the problem:

  1. The following test case should fail because the tree would have two default values. Instead, the resultant tree has no default values:
tree = Tree()

subtree = Tree()
subtree.condition(output=Action(value=100), condition="SubA")
subtree.set_default(output=Action(value=300))

cond_subtree = Tree()
cond_subtree.condition(output=Action(value=1000), condition="SubD")
cond_subtree.set_default(output=Action(value=3000))

tree.include_subtree(subtree)
tree.include_subtree(cond_subtree)

dot = tree.visualize(get_value_name=lambda x: str(x["value"][0]))
dot.view()
  1. In the following test case the tree should have two default values at different levels, yet one of the default values is lost:
tree = Tree()

subtree = Tree()
subtree.condition(output=Action(value=100), condition="SubA")
subtree.set_default(output=Action(value=300))

cond_subtree = Tree()
cond_subtree.condition(output=Action(value=1000), condition="SubD")
cond_subtree.set_default(output=Action(value=3000))

tree.include_subtree(subtree)
tree.include_subtree(cond_subtree, condition="SubC")

dot = tree.visualize(get_value_name=lambda x: str(x["value"][0]))
dot.view()

The proposed solution for these and the larger problem is at this branch: https://github.com/MogomotsiFM/dsp-decision-engine/tree/default-consistently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant