當前位置: 首頁>>代碼示例>>Python>>正文


Python Permutation.fromCycles方法代碼示例

本文整理匯總了Python中permutation.Permutation.fromCycles方法的典型用法代碼示例。如果您正苦於以下問題:Python Permutation.fromCycles方法的具體用法?Python Permutation.fromCycles怎麽用?Python Permutation.fromCycles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在permutation.Permutation的用法示例。


在下文中一共展示了Permutation.fromCycles方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: data

# 需要導入模塊: from permutation import Permutation [as 別名]
# 或者: from permutation.Permutation import fromCycles [as 別名]
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""This program displays the group data (as calculated by ``groups.about``) for
   a group generated from a list of permutations specified on the command line.
   Each permutation must be written as a sequence of cycles separated by ``/``,
   where each cycle is a sequence of positive integers separated by ``,``.  For
   example, the command:
  
       symdata.py 1,2/3,4 3,4,5
  
   displays the data for the group generated by ``(1 2)(3 4)`` and ``(3 4
   5)``."""

import sys
sys.path.insert(1, sys.path[0] + '/..')
from groups       import Symmetric
from groups.about import about, printAbout
from permutation  import Permutation

if len(sys.argv) < 2:
    sys.stderr.write("Usage: %s permutation ...\n" % (sys.argv[0],))
    sys.exit(2)
perms = [Permutation.fromCycles(map(int, b.split(',')) for b in a.split('/'))
	 for a in sys.argv[1:]]
perms.sort()
data = about(Symmetric(perms[-1].degree).generate(perms))
data["name"] = '⟨' + ', '.join(map(str, perms)) + '⟩'
printAbout(data)
print
開發者ID:foadnh,項目名稱:groups,代碼行數:31,代碼來源:symdata.py


注:本文中的permutation.Permutation.fromCycles方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。