def test_count_matrix_base_case(self): tree = u"(a,b);" t = TreeNode.read([tree]) res, _ = _count_matrix(t) exp = {'k': 0, 'l': 1, 'r': 1, 't': 0, 'tips': 2} self.assertEqual(res[t], exp) exp = {'k': 0, 'l': 0, 'r': 0, 't': 0, 'tips': 1} self.assertEqual(res[t[0]], exp) exp = {'k': 0, 'l': 0, 'r': 0, 't': 0, 'tips': 1} self.assertEqual(res[t[1]], exp)
def test_count_matrix_unbalanced(self): tree = u"((a,b)c, d);" t = TreeNode.read([tree]) res, _ = _count_matrix(t) exp = {'k': 0, 'l': 2, 'r': 1, 't': 0, 'tips': 3} self.assertEqual(res[t], exp) exp = {'k': 1, 'l': 1, 'r': 1, 't': 0, 'tips': 2} self.assertEqual(res[t[0]], exp) exp = {'k': 0, 'l': 0, 'r': 0, 't': 0, 'tips': 1} self.assertEqual(res[t[1]], exp) self.assertEqual(res[t[0][0]], exp) self.assertEqual(res[t[0][1]], exp)
def test_count_matrix_trifurcating_error(self): with self.assertRaises(ValueError): tree = u"((a,b,e)c, d);" t = TreeNode.read([tree]) _count_matrix(t)
def test_count_matrix_singleton_error(self): with self.assertRaises(ValueError): tree = u"(((a,b)c, d)root);" t = TreeNode.read([tree]) _count_matrix(t)