Example #1
0
def test_dacc_node():
    c = 0
    bt = Node(1, Node(2, Leaf(3), Leaf(4)), Leaf(5))
    res = bt.dacc(fun.add, lambda x, y: 0 if x - y < 0 else x - y, c)
    exp = Node(0, Node(1, Leaf(3), Leaf(0)), Leaf(0))
    assert exp == res
Example #2
0
def test_uacc_node():
    bt = Node(1, Leaf(2), Leaf(3))
    res = bt.uacc(fun.add)
    exp = Node(6, Leaf(2), Leaf(3))
    assert exp == res
Example #3
0
def test_dacc_leaf():
    c = 0
    bt = Leaf(1)
    res = bt.dacc(fun.add, lambda x, y: 0 if x - y < 0 else x - y, c)
    exp = Leaf(c)
    assert exp == res
Example #4
0
 def __remove_annotation(bt):
     v = bt.get_value()
     return Leaf(v.get_value()) if bt.is_leaf() else Node(
         v.get_value(), __remove_annotation(bt.get_left()),
         __remove_annotation(bt.get_right()))