def test_fenwick_tree_children(self): """Children test. Checks get_F(j) on 8 qubit register. Test: Verifies integrity of child nodes of the root.""" f = FenwickTree(8) self.assertEqual(f.get_node(7).children[0], f.get_node(3)) self.assertEqual(f.get_node(7).children[1], f.get_node(5)) self.assertEqual(f.get_node(7).children[2], f.get_node(6)) self.assertEqual(len(f.get_children_set(7)), 3)
def test_fenwick_tree_ancestors(self): """Ancestor test. Check validity of the get_update_set(j) method on 8 qubit register. Note that root is the last node. Test: Verifies integrity of ancestors of nodes within the tree.""" f = FenwickTree(8) self.assertEqual(len(f.get_update_set(7)), 0) # Is the parent of the middle child the root? self.assertEqual(f.get_update_set(3)[0], f.root) # Are the ancestors chained correctly? self.assertEqual(f.get_update_set(0)[0], f.get_node(1)) self.assertEqual(f.get_update_set(0)[1], f.get_node(3))