def test_expand_trees(self): # c1 = {1:[1, 2, 4, 6, 7, 8], 2:[3, 5, 9]} c1 = freqt.get_c1(self.root, 0.15) c2 = freqt.expand_trees(self.root, c1, 0.15, ['1', '2', 'root']) self.assertEqual(len(c2), 2) c3 = freqt.expand_trees(self.root, c2, 0.15, ['1', '2', 'root']) self.assertEqual(len(c3), 2) c3 = freqt.expand_trees(self.root, c2, 0.2, ['1', '2', 'root']) self.assertEqual(len(c3), 1)
def test_get_c1(self): c1 = freqt.get_c1(self.root, 0.05) self.assertEqual(len(c1), 3) self.assertTrue(self.subtree_1_str in c1.keys()) self.assertEqual(len(c1[self.subtree_1_str]), 6) self.assertTrue(self.subtree_2_str in c1.keys()) self.assertEqual(len(c1[self.subtree_2_str]), 3) self.assertTrue(self.subtree_r_str in c1.keys()) self.assertEqual(len(c1[self.subtree_r_str]), 1) c1 = freqt.get_c1(self.root, 0.15) self.assertEqual(len(c1), 2) self.assertTrue(self.subtree_1_str in c1.keys()) self.assertTrue(self.subtree_2_str in c1.keys()) c1 = freqt.get_c1(self.root, 0.8) self.assertEqual(len(c1), 0)
def test_update_rmo(self): # c1 = {1:[1, 2, 4, 6, 7, 8], 2:[3, 5, 9]} c1 = freqt.get_c1(self.root, 0.15) # Test all possible extensions off of c1. rmo_1 = c1[self.subtree_1_str] rmo_2 = c1[self.subtree_2_str] rmo_11 = freqt.update_rmo(self.root, rmo_1, 0, '1') self.assertEqual(len(rmo_11), 4) rmo_12 = freqt.update_rmo(self.root, rmo_1, 0, '2') self.assertEqual(len(rmo_12), 3) rmo_13 = freqt.update_rmo(self.root, rmo_1, 0, '3') self.assertEqual(len(rmo_13), 0) rmo_21 = freqt.update_rmo(self.root, rmo_2, 0, '1') self.assertEqual(len(rmo_21), 0) rmo_22 = freqt.update_rmo(self.root, rmo_2, 0, '2') self.assertEqual(len(rmo_22), 0) rmo_23 = freqt.update_rmo(self.root, rmo_2, 0, '3') self.assertEqual(len(rmo_23), 0) rmo_11 = freqt.update_rmo(self.root, rmo_1, 0, '1') self.assertEqual(len(rmo_11), 4) # Test extensions off of rmo_11. There should be no p=0 # extensions, but a few from p=1. rmo_111_p0 = freqt.update_rmo(self.root, rmo_11, 0, '1') self.assertEqual(len(rmo_111_p0), 0) rmo_111_p1 = freqt.update_rmo(self.root, rmo_11, 1, '1') self.assertEqual(len(rmo_111_p1), 2) rmo_112_p0 = freqt.update_rmo(self.root, rmo_11, 0, '2') self.assertEqual(len(rmo_112_p0), 0) rmo_112_p1 = freqt.update_rmo(self.root, rmo_11, 1, '2') self.assertEqual(len(rmo_112_p1), 3)