Commit 46400983 authored by Vincent Delecroix's avatar Vincent Delecroix

to_curver

parent e57ea0b9
Pipeline #53868489 failed with stage
in 11 minutes and 9 seconds
......@@ -22,12 +22,19 @@ try:
except ImportError:
flipper = None
try:
import curver
except ImportError:
curver = None
try:
import ppl
except ImportError:
ppl = None
error_msg = {
'curver': 'the function {} can only be called when the package curver is installed.',
'sage': 'the function {} can only be called when running inside of Sage. See http://www.sagemath.org/',
'surface_dynamics': 'the function {} only works when the package surface_dynamics is installed. See https://pypi.org/project/surface_dynamics/ for instructions.',
......@@ -38,6 +45,7 @@ error_msg = {
}
missing_mods = {
'curver': curver is None,
'sage': sage is None,
'flipper': flipper is None,
'ppl': ppl is None,
......
......@@ -13,7 +13,7 @@ from .permutation import *
from .misc import det2
from .triangulation import Triangulation
from .env import sage, surface_dynamics, ppl, flipper, require_package
from .env import curver, sage, surface_dynamics, ppl, flipper, require_package
if sage is not None:
from sage.misc.prandom import choice, shuffle
......@@ -377,6 +377,33 @@ class VeeringTriangulation(Triangulation):
return flipper.create_triangulation(F)
def to_curver(self):
r"""
Return the corresponding curver triangulation
EXAMPLES::
sage: from veerer import *
sage: T = VeeringTriangulation("(0,1,2)(~0,~1,~2)", [RED, RED, BLUE])
sage: T.to_curver()
[(~2, ~0, ~1), (0, 1, 2)]
"""
require_package('curver', 'to_curver')
ep = self._ep
F = []
for f in self.faces():
face = []
for e in f:
if ep[e] == e:
raise ValueError("curver do not accept folded edges")
if ep[e] < e:
face.append(~int(ep[e]))
else:
face.append(int(e))
F.append(tuple(face))
return curver.create_triangulation(F)
def __eq__(self, other):
if type(self) != type(other):
raise TypeError
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment