本文整理匯總了Python中permutation.Permutation類的典型用法代碼示例。如果您正苦於以下問題:Python Permutation類的具體用法?Python Permutation怎麽用?Python Permutation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Permutation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_klien4
def test_klien4(self):
a = Permutation.read_cycle_form([[1,2],[3,4]],4)
b = Permutation.read_cycle_form([[1,3],[2,4]],4)
G = PermGroup([a,b])
oG = OrbitGraph(G,(1,2))
self.assertTrue(tuple(sorted(oG.edges)) == ((1,2),(2,1),(3,4),(4,3)))
self.assertTrue(oG.ad_list == [[2],[1],[4],[3]])
示例2: test_schreier_graph_construction
def test_schreier_graph_construction(self):
s1 = Permutation.read_cycle_form([[2,3]], 4)
s2 = Permutation.read_cycle_form([[1,2,4]], 4)
gens = [s1,s2]
identity = Permutation([1,2,3,4])
s_g = _schreier_graph(2, gens, identity)
self.assertEqual(s_g, [s2,identity,s1,s2])
示例3: test_identity
def test_identity(self):
a = Permutation([2, 3, 1, 4])
c = Permutation([])
self.assertEqual(a ** -1 * a, Permutation.read_cycle_form([], 4))
self.assertEqual(a * a ** -1, Permutation.read_cycle_form([], 4))
self.assertEqual((a * a ** -1)._func, (1, 2, 3, 4))
self.assertEqual(c._func, ())
示例4: test_coset_enumeration
def test_coset_enumeration(self):
g1 = Permutation.read_cycle_form([[1,2,3,4]], 4)
g2 = Permutation.read_cycle_form([[1,2]], 4)
h1 = Permutation.read_cycle_form([[1,2,3]], 4)
h2 = Permutation.read_cycle_form([[1,2]], 4)
G = PermGroup([g1, g2])
H = PermGroup([h1, h2])
cosets = G._left_cosets(H)
total = 0
elements = []
for coset in cosets:
temp_eles = coset._list_elements()
elements += temp_eles
self.assertEqual(len(temp_eles),len(H))
total += len(temp_eles)
self.assertEqual(len(G), total)
self.assertEqual(sorted(G._list_elements()), sorted(elements))
cosets = G._right_cosets(H)
total = 0
elements = []
for coset in cosets:
temp_eles = coset._list_elements()
elements += temp_eles
self.assertEqual(len(temp_eles),len(H))
total += len(temp_eles)
self.assertEqual(len(G), total)
self.assertEqual(sorted(G._list_elements()), sorted(elements))
示例5: test_len
def test_len(self):
s1 = Permutation.read_cycle_form([[1,2,3,4]], 4)
s2 = Permutation.read_cycle_form([[1,2]], 4)
G = PermGroup([s1, s2])
self.assertEqual(len(G), len(G._list_elements()))
self.assertEqual(len(G), 24)
self.assertTrue(Permutation.read_cycle_form([[3,4]], 4) in G._list_elements())
示例6: test_coset_reps
def test_coset_reps(self):
s1 = Permutation.read_cycle_form([[2,3]], 4)
s2 = Permutation.read_cycle_form([[1,2,4]], 4)
gens = [s1,s2]
identity = Permutation([1,2,3,4])
s_g = _schreier_graph(2, gens, identity)
cosets = _coset_reps(s_g, identity)
self.assertEqual(cosets, [Permutation.read_cycle_form([[1,4,2]], 4),identity,s1,s2])
示例7: test_cycle_form_reading
def test_cycle_form_reading(self):
a = Permutation([2, 3, 1, 4])
b = Permutation.read_cycle_form([], 4)
e = Permutation([1, 2, 3, 4])
self.assertEqual(b, e)
self.assertEqual(a, Permutation.read_cycle_form([[1, 2, 3]], 4))
self.assertEqual(a, Permutation.read_cycle_form([[2, 3, 1]], 4))
self.assertEqual(a, Permutation.read_cycle_form([[3, 1, 2]], 4))
示例8: test_base_image_member
def test_base_image_member(self):
h1 = Permutation.read_cycle_form([[3,4,5,6,7]], 7)
h2 = Permutation.read_cycle_form([[3,4]], 7)
H = PermGroup.fixed_base_group([h1, h2], [3,4,5,6])
self.assertEqual(H.base, [3,4,5,6])
image1 = [1,2,3,4]
image2 = [5,3,4,6]
self.assertTrue(H.base_image_member(image1) is None)
self.assertEqual(H.base_image_member(image2), Permutation.read_cycle_form([[3,5,4]],7))
示例9: test_fixed_base_group
def test_fixed_base_group(self):
g1 = Permutation.read_cycle_form([[1,2,3,4,5,6]], 6)
g2 = Permutation.read_cycle_form([[1,2]], 6)
h1 = Permutation.read_cycle_form([[3,4,5,6]], 6)
h2 = Permutation.read_cycle_form([[3,4]], 6)
G = PermGroup.fixed_base_group([g1, g2], [5,4])
H = PermGroup.fixed_base_group([h1, h2], [1,2,3,4,5,6])
N = PermGroup.fixed_base_group([g1,h1], [])
self.assertEqual(G.base[:2], [5,4])
self.assertEqual(H.base[:4], [1,2,3,4])
self.contains_membership_test(G, H)
示例10: afterGenerateNameList
def afterGenerateNameList(f, l):
nameList = []
nameList.append(f)
nameList.append(l)
obj = Permutation()
obj.words = nameList
rst = obj.permutationList()
if rst:
variables.name.extend(rst)
#字符串去重
variables.name = list(set(variables.name))
示例11: doGenerate
def doGenerate():
variables.head = handleList(variables.head)
variables.tail = handleList(variables.tail)
variables.name.append("")
variables.birthday.append("")
variables.extinfo.append("")
variables.dict_max.append("")
variables.tail.append("")
variables.head.append("")
variables.year.append("")
# variables.lett.append("")
variables.email.append("")
variables.qq.append("")
variables.phoneNumer.append("")
f = open('./result.txt', 'w')
for birstdayItem in variables.birthday:
for nameItem in variables.name:
for extinfoItem in variables.extinfo:
for dictMaxItem in variables.dict_max:
for yearItem in variables.year:
for phoneItem in variables.phoneNumer:
for qqItem in variables.qq:
for emailItem in variables.email:
preS = birstdayItem + nameItem + extinfoItem\
+ dictMaxItem + yearItem + phoneItem\
+ qqItem + emailItem
if len(preS) < variables.minLen or len(preS) > variables.maxLen:
continue
obj = Permutation()
obj.words = [birstdayItem, nameItem, extinfoItem, \
dictMaxItem, \
yearItem, phoneItem, qqItem, \
emailItem]
obj.words = handleList(obj.words)
rst = obj.permutationList()
for s in rst:
if len(s) < variables.minLen or len(s) > variables.maxLen:
break
for tailItem in variables.tail:
for headItem in variables.head:
s2 = headItem + s + tailItem
if len(s2) >= variables.minLen and len(s2) <= variables.maxLen:
print s2
if const.isRelease:
f.write(s2);
f.write('\n')
f.close()
print "Done!"
示例12: test_orbit
def test_orbit(self):
g1 = Permutation.read_cycle_form([[1,2,3,4]], 4)
g2 = Permutation.read_cycle_form([[1,2]], 4)
base = [3,4,1]
reverse_priority = [3,4,1,2]
G = PermGroup.fixed_base_group([g1, g2], base)
self.assertEqual(G.orbit(1), [1,2,3,4])
self.assertEqual(G.orbit(1, stab_level = 0), [1,2,3,4])
self.assertEqual(G.orbit(1, stab_level = 1), [1,2,4])
self.assertEqual(G.orbit(1, stab_level = 2), [1,2])
self.assertEqual(G.orbit(1, stab_level = 3), [1])
self.assertEqual(G.orbit(1, key = lambda x : reverse_priority[x - 1]), [3,4,1,2])
示例13: test_schreier_generators
def test_schreier_generators(self):
s1 = Permutation.read_cycle_form([[2,3]], 4)
s2 = Permutation.read_cycle_form([[1,2,4]], 4)
gens = [s1,s2]
identity = Permutation([1,2,3,4])
s_g = _schreier_graph(2, gens, identity)
cosets = _coset_reps(s_g, identity)
s_gen = _schreier_generators(2, cosets, gens, identity)
gen_1 = Permutation.read_cycle_form([[3,4]], 4)
gen_2 = Permutation.read_cycle_form([[1,3,4]], 4)
gen_3 = Permutation.read_cycle_form([[1,3]], 4)
self.assertEqual(s_gen, [gen_1, gen_2, gen_3])
示例14: test_read_partitions
def test_read_partitions(self):
a = Partition([[1], [2], [3], [4], [5]])
b = Partition([[2], [3], [4], [5], [1]])
c = Partition([[2], [1], [4], [3], [5]])
perm1 = Permutation([2, 3, 4, 5, 1])
perm1alt = Permutation.read_partitions(a, b)
perm2 = Permutation([2, 1, 4, 3, 5])
perm2alt = Permutation.read_partitions(a, c)
perm3 = Permutation([5, 2, 1, 4, 3])
perm3alt = Permutation.read_partitions(b, c)
self.assertEqual(perm1, perm1alt)
self.assertEqual(perm2, perm2alt)
self.assertEqual(perm3, perm3alt)
示例15: test_coset
def test_coset(self):
g1 = Permutation.read_cycle_form([[1,2,3,4]], 4)
g2 = Permutation.read_cycle_form([[1,2]], 4)
h1 = Permutation.read_cycle_form([[1,2,3]], 4)
h2 = Permutation.read_cycle_form([[1,2]], 4)
G = PermGroup([g1, g2])
H = PermGroup([h1, h2])
coset = sorted((H*g1)._list_elements())
for c in coset:
self.assertEqual(sorted((H*c)._list_elements()), coset)
self.assertEqual(len(H), len(coset))
coset = sorted((g1*H)._list_elements())
for c in coset:
self.assertEqual(sorted((c*H)._list_elements()), coset)
self.assertEqual(len(H), len(coset))