Esempio n. 1
0
 def test_gdata(self):
     """DndTokenizer should work as expected on real data"""
     exp = \
         ['(', '(', 'xyz', ':', '0.28124', ',', '(', 'def', ':', '0.24498',
          ',', 'mno', ':', '0.03627', ')', ':', '0.17710', ')', ':',
          '0.04870', ',', 'abc', ':', '0.05925', ',', '(', 'ghi', ':',
          '0.06914', ',', 'jkl', ':', '0.13776', ')', ':', '0.09853', ')',
          ';']
     # split it up for debugging on an item-by-item basis
     obs = list(_dnd_tokenizer(sample))
     self.assertEqual(len(obs), len(exp))
     for i, j in zip(obs, exp):
         self.assertEqual(i, j)
     # try it all in one go
     self.assertEqual(list(_dnd_tokenizer(sample)), exp)
Esempio n. 2
0
 def test_gdata(self):
     """DndTokenizer should work as expected on real data"""
     exp = \
         ['(', '(', 'xyz', ':', '0.28124', ',', '(', 'def', ':', '0.24498',
          ',', 'mno', ':', '0.03627', ')', ':', '0.17710', ')', ':',
          '0.04870', ',', 'abc', ':', '0.05925', ',', '(', 'ghi', ':',
          '0.06914', ',', 'jkl', ':', '0.13776', ')', ':', '0.09853', ')',
          ';']
     # split it up for debugging on an item-by-item basis
     obs = list(_dnd_tokenizer(sample))
     self.assertEqual(len(obs), len(exp))
     for i, j in zip(obs, exp):
         self.assertEqual(i, j)
     # try it all in one go
     self.assertEqual(list(_dnd_tokenizer(sample)), exp)
Esempio n. 3
0
 def test_minimal(self):
     """DndTokenizer should work as expected a minimal tree without names"""
     exp = ['(', ')', ';']
     obs = list(_dnd_tokenizer(minimal))
     self.assertEqual(obs, exp)
Esempio n. 4
0
 def test_missing_tip_name(self):
     """DndTokenizer should work as expected on trees with a missing name"""
     exp = ['(', '(', 'a', ',', 'b', ')', ',', '(', 'c', ',', ')', ')', ';']
     obs = list(_dnd_tokenizer(missing_tip_name))
     self.assertEqual(obs, exp)
Esempio n. 5
0
 def test_nonames(self):
     """DndTokenizer should work as expected on trees with no names"""
     exp = ['(', '(', ',', ')', ',', '(', ',', ')', ')', ';']
     obs = list(_dnd_tokenizer(no_names))
     self.assertEqual(obs, exp)
Esempio n. 6
0
 def test_minimal(self):
     """DndTokenizer should work as expected a minimal tree without names"""
     exp = ['(', ')', ';']
     obs = list(_dnd_tokenizer(minimal))
     self.assertEqual(obs, exp)
Esempio n. 7
0
 def test_missing_tip_name(self):
     """DndTokenizer should work as expected on trees with a missing name"""
     exp = ['(', '(', 'a', ',', 'b', ')', ',', '(', 'c', ',', ')', ')', ';']
     obs = list(_dnd_tokenizer(missing_tip_name))
     self.assertEqual(obs, exp)
Esempio n. 8
0
 def test_nonames(self):
     """DndTokenizer should work as expected on trees with no names"""
     exp = ['(', '(', ',', ')', ',', '(', ',', ')', ')', ';']
     obs = list(_dnd_tokenizer(no_names))
     self.assertEqual(obs, exp)