def test_group_size(self):
     cf  = Permutation.read_cycle_form
     a = cf([[1, 2, 3,4,5]],5)
     b = cf([[1,2,3]], 5)
     e = cf([],5)
     base, _, _, graphs = schreier_sims_algorithm_fixed_base([a,b],[1,2,3,4,5], e)
     self.assertEqual(group_size(graphs),60)
 def test_memebership_index(self):
     cf  = Permutation.read_cycle_form
     a = cf([[1, 2, 3,4,5]],5)
     b = cf([[1,2,3]], 5)
     c = cf([[1,2]], 5)
     e = cf([],5)
     ordering = [3,5,2,1,4]
     base, _, _, graphs = schreier_sims_algorithm_fixed_base([a,b], ordering, e)
     S5_base, _, _, S5_graphs = schreier_sims_algorithm_fixed_base([a,c], ordering, e)
     real_group = []
     S5_group = []
     
     ele_key = ordering_to_key(ordering)        
     perm_key = ordering_to_perm_key(ordering)
     
     for index in range(group_size(S5_graphs)):
         S5_group.append(element_at_index(S5_base, S5_graphs, index, e, key=ele_key))
      
     self.assertEquals(len(S5_group), 120)
     self.assertEquals(S5_group, sorted(S5_group, key = perm_key))
     
     
     for index in range(group_size(graphs)):
         real_group.append(element_at_index(base, graphs, index, e, key=ele_key))
          
     self.assertEquals(len(real_group), 60)
     self.assertEquals(real_group, sorted(real_group, key = perm_key))
     
     for ele in S5_group:
         cand_index = membership_index(ele, graphs, base, e, key = ele_key)
         if cand_index > -1:
             #print("{}: {} {}?".format(cand_index, ele, real_group[cand_index]))
             self.assertTrue(ele in real_group)
             self.assertEquals(real_group[cand_index], ele)
         else:
             self.assertFalse(ele in real_group)
 def test_element_at_index(self):
     cf  = Permutation.read_cycle_form
     a = cf([[1, 2, 3,4,5]],5)
     b = cf([[1,2,3]], 5)
     e = cf([],5)
     ordering = [3,5,2,1,4]
     base, _, _, graphs = schreier_sims_algorithm_fixed_base([a,b], ordering, e)
     full_group = []
     ele_key = ordering_to_key(ordering)        
     perm_key = ordering_to_perm_key(ordering)
     for index in range(group_size(graphs)):
         full_group.append(element_at_index(base, graphs, index, e, key=ele_key))
     ordered_group = sorted(full_group, key = perm_key)
     #for x,y in zip(full_group, ordered_group):
         #print("{!s:<20} {!s:<20}".format(x,y))
     self.assertEqual(full_group, ordered_group)
Example #4
0
 def order(self):
     return schreier_sims_tools.group_size(self.schreier_graphs)