def bytes_n_cobs(mfld): """ Return a bytestring encoding of the manifold and a list of basis changes that convert the combinatorial basis of the decoded bytestring back to the original peripheral basis of the manifold, and a permutation to be applied to the cusp indices. """ cobs = mfld.set_peripheral_curves('combinatorial', return_matrices=True) bytestring = mfld._to_bytes() encoded_perm = 0 N = Manifold('empty') N._from_bytes(bytestring) N.set_peripheral_curves('combinatorial') mfld.set_peripheral_curves(cobs) # put it back the way it was isoms = mfld.isomorphisms_to(N) abcd = False while isoms: pick_one = isoms.pop() abcd = tuples(pick_one) if abcd: break if not abcd: print('No orientation preserving isometries????') return bytestring, cobs, 0 perm = pick_one.cusp_images() for n in range(mfld.num_cusps()): a, b, c, d = abcd[n] cobs[perm[n]] = [[a, c], [b, d]] encoded_perm |= (n << (perm[n] << 2)) return bytestring, cobs, encoded_perm
def _test_against_known_canonical_retriangulations(): from snappy import Manifold for name, bytes_ in _known_canonical_retriangulations: M = Manifold(name); K = verified_canonical_retriangulation(M) L = Manifold('empty'); L._from_bytes(bytes_) if not len(K.isomorphisms_to(L)): raise Exception('%s failed' % name)