

def _pgroup_calcs():
    'Return the permutation groups for each of the polyhedra and the face\n    definitions: tetrahedron, cube, octahedron, dodecahedron, icosahedron,\n    tetrahedron_faces, cube_faces, octahedron_faces, dodecahedron_faces,\n    icosahedron_faces\n\n    (This author didn\'t find and didn\'t know of a better way to do it though\n    there likely is such a way.)\n\n    Although only 2 permutations are needed for a polyhedron in order to\n    generate all the possible orientations, a group of permutations is\n    provided instead. A set of permutations is called a "group" if::\n\n    a*b = c (for any pair of permutations in the group, a and b, their\n    product, c, is in the group)\n\n    a*(b*c) = (a*b)*c (for any 3 permutations in the group associativity holds)\n\n    there is an identity permutation, I, such that I*a = a*I for all elements\n    in the group\n\n    a*b = I (the inverse of each permutation is also in the group)\n\n    None of the polyhedron groups defined follow these definitions of a group.\n    Instead, they are selected to contain those permutations whose powers\n    alone will construct all orientations of the polyhedron, i.e. for\n    permutations ``a``, ``b``, etc... in the group, ``a, a**2, ..., a**o_a``,\n    ``b, b**2, ..., b**o_b``, etc... (where ``o_i`` is the order of\n    permutation ``i``) generate all permutations of the polyhedron instead of\n    mixed products like ``a*b``, ``a*b**2``, etc....\n\n    Note that for a polyhedron with n vertices, the valid permutations of the\n    vertices exclude those that do not maintain its faces. e.g. the\n    permutation BCDE of a square\'s four corners, ABCD, is a valid\n    permutation while CBDE is not (because this would twist the square).\n\n    Examples\n    ========\n\n    The is_group checks for: closure, the presence of the Identity permutation,\n    and the presence of the inverse for each of the elements in the group. This\n    confirms that none of the polyhedra are true groups:\n\n    >>> from sympy.combinatorics.polyhedron import (\n    ... tetrahedron, cube, octahedron, dodecahedron, icosahedron)\n    ...\n    >>> polyhedra = (tetrahedron, cube, octahedron, dodecahedron, icosahedron)\n    >>> [h.pgroup.is_group for h in polyhedra]\n    ...\n    [True, True, True, True, True]\n\n    Although tests in polyhedron\'s test suite check that powers of the\n    permutations in the groups generate all permutations of the vertices\n    of the polyhedron, here we also demonstrate the powers of the given\n    permutations create a complete group for the tetrahedron:\n\n    >>> from sympy.combinatorics import Permutation, PermutationGroup\n    >>> for h in polyhedra[:1]:\n    ...     G = h.pgroup\n    ...     perms = set()\n    ...     for g in G:\n    ...         for e in range(g.order()):\n    ...             p = tuple((g**e).array_form)\n    ...             perms.add(p)\n    ...\n    ...     perms = [Permutation(p) for p in perms]\n    ...     assert PermutationGroup(perms).is_group\n\n    In addition to doing the above, the tests in the suite confirm that the\n    faces are all present after the application of each permutation.\n\n    References\n    ==========\n\n    http://dogschool.tripod.com/trianglegroup.html\n    '

    def _pgroup_of_double(polyh, ordered_faces, pgroup):
        n = len(ordered_faces[0])
        fmap = dict(zip(ordered_faces, range(len(ordered_faces))))
        flat_faces = flatten(ordered_faces)
        new_pgroup = []
        for (i, p) in enumerate(pgroup):
            h = polyh.copy()
            h.rotate(p)
            c = h.corners
            reorder = unflatten([c[j] for j in flat_faces], n)
            reorder = [tuple(map(as_int, minlex(f, directed=False, is_set=True))) for f in reorder]
            new_pgroup.append(Perm([fmap[f] for f in reorder]))
        return new_pgroup
    tetrahedron_faces = [(0, 1, 2), (0, 2, 3), (0, 3, 1), (1, 2, 3)]
    _t_pgroup = [Perm([[1, 2, 3], [0]]), Perm([[0, 1, 2], [3]]), Perm([[0, 3, 2], [1]]), Perm([[0, 3, 1], [2]]), Perm([[0, 1], [2, 3]]), Perm([[0, 2], [1, 3]]), Perm([[0, 3], [1, 2]])]
    tetrahedron = Polyhedron(range(4), tetrahedron_faces, _t_pgroup)
    cube_faces = [(0, 1, 2, 3), (0, 1, 5, 4), (1, 2, 6, 5), (2, 3, 7, 6), (0, 3, 7, 4), (4, 5, 6, 7)]
    _c_pgroup = [Perm(p) for p in [[1, 2, 3, 0, 5, 6, 7, 4], [4, 0, 3, 7, 5, 1, 2, 6], [4, 5, 1, 0, 7, 6, 2, 3], [1, 0, 4, 5, 2, 3, 7, 6], [6, 2, 1, 5, 7, 3, 0, 4], [6, 7, 3, 2, 5, 4, 0, 1], [3, 7, 4, 0, 2, 6, 5, 1], [4, 7, 6, 5, 0, 3, 2, 1], [6, 5, 4, 7, 2, 1, 0, 3], [0, 3, 7, 4, 1, 2, 6, 5], [5, 1, 0, 4, 6, 2, 3, 7], [5, 6, 2, 1, 4, 7, 3, 0], [7, 4, 0, 3, 6, 5, 1, 2]]]
    cube = Polyhedron(range(8), cube_faces, _c_pgroup)
    octahedron_faces = [(0, 1, 2), (0, 2, 3), (0, 3, 4), (0, 1, 4), (1, 2, 5), (2, 3, 5), (3, 4, 5), (1, 4, 5)]
    octahedron = Polyhedron(range(6), octahedron_faces, _pgroup_of_double(cube, cube_faces, cube_faces))
    dodecahedron_faces = [(0, 1, 2, 3, 4), (0, 1, 6, 10, 5), (1, 2, 7, 11, 6), (2, 3, 8, 12, 7), (3, 4, 9, 13, 8), (0, 4, 9, 14, 5), (5, 10, 16, 15, 14), (6, 10, 16, 17, 11), (7, 11, 17, 18, 12), (8, 12, 18, 19, 13), (9, 13, 19, 15, 14), (15, 16, 17, 18, 19)]

    def _string_to_perm(s):
        rv = [Perm(range(20))]
        p = None
        for si in s:
            if (si not in '01'):
                count = (int(si) - 1)
            else:
                count = 1
                if (si == '0'):
                    p = _f0
                elif (si == '1'):
                    p = _f1
            rv.extend(([p] * count))
        return Perm.rmul(*rv)
    _f0 = Perm([1, 2, 3, 4, 0, 6, 7, 8, 9, 5, 11, 12, 13, 14, 10, 16, 17, 18, 19, 15])
    _f1 = Perm([5, 0, 4, 9, 14, 10, 1, 3, 13, 15, 6, 2, 8, 19, 16, 17, 11, 7, 12, 18])
    _dodeca_pgroup = ([_f0, _f1] + [_string_to_perm(s) for s in '\n    0104 140 014 0410\n    010 1403 03104 04103 102\n    120 1304 01303 021302 03130\n    0412041 041204103 04120410 041204104 041204102\n    10 01 1402 0140 04102 0412 1204 1302 0130 03120'.strip().split()])
    dodecahedron = Polyhedron(range(20), dodecahedron_faces, _dodeca_pgroup)
    icosahedron_faces = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 1, 5], [1, 6, 7], [1, 2, 7], [2, 7, 8], [2, 3, 8], [3, 8, 9], [3, 4, 9], [4, 9, 10], [4, 5, 10], [5, 6, 10], [1, 5, 6], [6, 7, 11], [7, 8, 11], [8, 9, 11], [9, 10, 11], [6, 10, 11]]
    icosahedron = Polyhedron(range(12), icosahedron_faces, _pgroup_of_double(dodecahedron, dodecahedron_faces, _dodeca_pgroup))
    return (tetrahedron, cube, octahedron, dodecahedron, icosahedron, tetrahedron_faces, cube_faces, octahedron_faces, dodecahedron_faces, icosahedron_faces)

dataset/ETHPy150Open sympy/sympy/sympy/combinatorics/polyhedron.py _pgroup_calcs/VarMisuse@753/2226 `_c_pgroup`->`cube_faces`