import sys sys.path.insert(1, sys.path[0] + '/..') import groups from groups.about import about g = groups.Symmetric(4) data = about(g) for subgr in sorted(data["subgroups"], key=lambda s: data["subgroups"][s]["index"]): print '{' + ', '.join(data["subgroups"][subgr]["elements"]) + '}' for gen in data["subgroups"][subgr]["generators"]: print ' {' + ', '.join(gen) + '}' print
#!/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
#!/usr/bin/python import json import re import sys sys.path.insert(1, sys.path[0] + '/..') from groups.about import about from groups.read import readName if len(sys.argv) < 2: raise SystemExit("Usage: %s group ...\n" % (sys.argv[0], )) sys.stdout.write('[\n') first = True for gname in sys.argv[1:]: g = readName(gname) if first: first = False else: sys.stdout.write(',\n') sys.stdout.write('\n') data = about(g) shown = json.dumps(data, sort_keys=True, indent=4, separators=(',', ': ')) sys.stdout.write(re.sub('^', ' ' * 4, shown, flags=re.M)) sys.stdout.write('\n\n]\n')
# -*- 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