Example #1
0
 def _pgroup_of_double(polyh, ordered_faces, pgroup):
     n = len(ordered_faces[0])
     # the vertices of the double which sits inside a give polyhedron
     # can be found by tracking the faces of the outer polyhedron.
     # A map between face and the vertex of the double is made so that
     # after rotation the position of the vertices can be located
     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 corners in the order they should appear when
         # enumerating the faces
         reorder = unflatten([c[j] for j in flat_faces], n)
         # make them canonical
         reorder = [tuple(map(as_int,
                    minlex(f, directed=False, is_set=True)))
                    for f in reorder]
         # map face to vertex: the resulting list of vertices are the
         # permutation that we seek for the double
         new_pgroup.append(Perm([fmap[f] for f in reorder]))
     return new_pgroup
Example #2
0
 def _pgroup_of_double(polyh, ordered_faces, pgroup):
     n = len(ordered_faces[0])
     # the vertices of the double which sits inside a give polyhedron
     # can be found by tracking the faces of the outer polyhedron.
     # A map between face and the vertex of the double is made so that
     # after rotation the position of the vertices can be located
     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 corners in the order they should appear when
         # enumerating the faces
         reorder = unflatten([c[j] for j in flat_faces], n)
         # make them canonical
         reorder = [tuple(map(as_int,
                    minlex(f, directed=False, is_set=True)))
                    for f in reorder]
         # map face to vertex: the resulting list of vertices are the
         # permutation that we seek for the double
         new_pgroup.append(Perm([fmap[f] for f in reorder]))
     return new_pgroup
Example #3
0
def test_unflatten():
    r = list(range(10))
    assert unflatten(r) == list(zip(r[::2], r[1::2]))
    assert unflatten(r, 5) == [tuple(r[:5]), tuple(r[5:])]
    raises(ValueError, lambda: unflatten(list(range(10)), 3))
    raises(ValueError, lambda: unflatten(list(range(10)), -2))
Example #4
0
def test_unflatten():
    r = range(10)
    assert unflatten(r) == zip(r[::2], r[1::2])
    assert unflatten(r, 5) == [tuple(r[:5]), tuple(r[5:])]
    raises(ValueError, lambda: unflatten(range(10), 3))
    raises(ValueError, lambda: unflatten(range(10), -2))
Example #5
0
def test_unflatten():
    r = range(10)
    assert unflatten(r) == zip(r[::2], r[1::2])
    assert unflatten(r, 5) == [tuple(r[:5]), tuple(r[5:])]
    raises(ValueError, "unflatten(range(10), 3)")
    raises(ValueError, "unflatten(range(10), -2)")