def test_leaf_internal_idx(self): sumTree = SumTree(10, [Item("A", 6), Item("A", 3), Item("A", 1), Item("A", 0), Item("A", 9), Item("A", 8), Item("A", 5), Item("A", 8), Item("A", 7), Item("A", -1)]) for idx in range(sumTree.get_num_leaves()): self.assertEqual(sumTree.tree[idx].idx, idx - sumTree.idx_shift)
def test_num_leaves(self): items = [Item("A", 6), Item("A", 3), Item("A", 1), Item("A", 0), Item("A", 9), Item("A", 8), Item("A", 5), Item("A", 8), Item("A", 7), Item("A", -1)] sumTree = SumTree(10, items) self.assertEqual(sumTree.get_num_leaves(), len(items))