Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require SageMath to be installed #34

Merged
merged 11 commits into from
Nov 25, 2023
25 changes: 23 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,25 @@ jobs:
- optionals: "sage,sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper"
sagelib: "10.0"
python: "3.10.5"
# Test optional dependencies in isolation
- optionals: "sage"
sagelib: "10.0"
python: "3.10.5"
- optionals: "sage,sage_flatsurf"
sagelib: "10.0"
python: "3.10.5"
- optionals: "sage,pyeantic"
sagelib: "10.0"
python: "3.10.5"
- optionals: "sage,pyintervalxt"
sagelib: "10.0"
python: "3.10.5"
- optionals: "sage,surface_dynamics"
sagelib: "10.0"
python: "3.10.5"
- optionals: "sage,flipper"
sagelib: "10.0"
python: "3.10.5"
steps:
- uses: actions/checkout@v2
with: { submodules: recursive }
Expand All @@ -42,8 +61,10 @@ jobs:
- name: Install dependencies
shell: bash -l {0}
run: |
mamba install -n test sagelib=${{ matrix.sagelib }}
echo "sagelib ==${{ matrix.sagelib }}" >> $CONDA_PREFIX/conda-meta/pinned
if (echo "${{ matrix.optionals }}" | grep sage); then
mamba install -n test sagelib=${{ matrix.sagelib }}
echo "sagelib ==${{ matrix.sagelib }}" >> $CONDA_PREFIX/conda-meta/pinned
fi

while read; do
optional=$(echo "$REPLY" | grep -o '# optional: [^ ]*' | awk '{ print $3; }') || true
Expand Down
17 changes: 5 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
Veerer
======

Veerer is a Python package to deal with veering triangulations of surfaces and
their associated flat structures. It can in particular be used to provide
representatives of pseudo-Anosov mapping classes of surfaces. The theoretical
background is based on ideas of I. Agol and F. Guéritaud, and is developed in:
Veerer is a package for `SageMath <https://www.sagemath.org>`_ to deal with
veering triangulations of surfaces and their associated flat structures. It can
in particular be used to provide representatives of pseudo-Anosov mapping
classes of surfaces. The theoretical background is based on ideas of I. Agol
and F. Guéritaud, and is developed in:

M. Bell, V. Delecroix, V. Gadre, R. Gutiérrez-Romo, S. Schleimer,
"Coding Teichmüller flow using veering triangulations",
`arXiv:1909.00890 <https://arxiv.org/abs/1909.00890>`_.

To install this package you only need Python but additional features are
available if this package is used inside `SageMath
<https://www.sagemath.org/>`_.

Computations involving polytopes are only available if the Python package
`pplpy <https://github.com/sagemath/pplpy>`_ is available. It is installed
by default with SageMath, version 8.7 or above.

Example
-------

Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ name: veerer-build
channels:
- conda-forge
dependencies:
- cython
- pytest
- pytest-xdist
- ipywidgets
Expand Down
2 changes: 0 additions & 2 deletions veerer/automaton.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ def to_graph(self, directed=True, multiedges=True, loops=True):
sage: A.to_graph(directed=False, multiedges=False, loops=True)
Looped graph on 86 vertices
"""
require_package('sage', 'to_graph')

if directed:
from sage.graphs.digraph import DiGraph
G = DiGraph(loops=loops, multiedges=multiedges)
Expand Down
37 changes: 4 additions & 33 deletions veerer/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,10 @@

CHECK = False

try:
import sage.all
import sage
except ImportError:
sage = None
import random
op_LT = 0
op_LE = 1
op_EQ = 2
op_NE = 3
op_GT = 4
op_GE = 5
def rich_to_bool(op, c):
if op == op_EQ:
return c == 0
elif op == op_NE:
return c != 0
elif op == op_LT:
return c < 0
elif op == op_LE:
return c <= 0
elif op == op_GE:
return c >= 0
elif op == op_GT:
return c > 0
else:
raise RuntimeError
else:
import sage.misc.prandom as random
from sage.structure.richcmp import op_LT, op_LE, op_EQ, op_NE, op_GT, op_GE, rich_to_bool
import sage.all
import sage
import sage.misc.prandom as random
from sage.structure.richcmp import op_LT, op_LE, op_EQ, op_NE, op_GT, op_GE, rich_to_bool


try:
Expand Down Expand Up @@ -90,8 +64,6 @@ def rich_to_bool(op, c):
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 https://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.',

'flipper': 'the function {} only works when the package flipper is installed. See https://pypi.org/project/flipper/ for instructions',
Expand All @@ -103,7 +75,6 @@ def rich_to_bool(op, c):

missing_mods = {
'curver': curver is None,
'sage': sage is None,
'flipper': flipper is None,
'ppl': ppl is None,
'surface_dynamics': surface_dynamics is None,
Expand Down
3 changes: 0 additions & 3 deletions veerer/flip_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ def copy(self):
return F

def matrix(self, twist=True):
require_package('sage', 'matrix')
from sage.rings.all import ZZ
from sage.matrix.special import identity_matrix
m = identity_matrix(ZZ, self._start.num_edges())
Expand Down Expand Up @@ -321,7 +320,6 @@ def inverse(self):
return F

def matrix_inverse(self, twist=True):
require_package('sage', 'matrix')
from sage.rings.all import ZZ
from sage.matrix.special import identity_matrix
m = identity_matrix(ZZ, self._start.num_edges())
Expand Down Expand Up @@ -520,7 +518,6 @@ def self_similar_widths_and_heights(self):
sage: f.start().colouring_from_xy(x, y)[:9] == f.end_colouring()
True
"""
require_package('sage', 'self_similar_surface')
from sage.rings.qqbar import AA

wm = self.inverse().matrix() # matrix: widths_end -> widths_start
Expand Down
3 changes: 0 additions & 3 deletions veerer/polyhedron/linear_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

from ..env import require_package, sage, ppl

require_package('sage', 'linear_expression')

from sage.categories.modules import Modules

from sage.structure.unique_representation import UniqueRepresentation
Expand Down Expand Up @@ -563,7 +561,6 @@ def cone(self, backend='sage'):
from .cone import Cone_ppl
return Cone_ppl(QQ, ppl.C_Polyhedron(self.ppl()))
elif backend == 'sage':
require_package('sage', 'cone')
from .cone import Cone_sage
ieqs, eqns = self.ieqs_eqns()
return Cone_sage._new(ieqs, eqns)
Expand Down
1 change: 0 additions & 1 deletion veerer/triangulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,6 @@ def homology_matrix(self):
[ 1 0 1 0 1 1 0]
[ 0 1 0 0 -1 0 0]
"""
require_package('sage', 'homology_matrix')
from sage.matrix.constructor import matrix
from sage.rings.integer_ring import ZZ

Expand Down
2 changes: 1 addition & 1 deletion veerer/veering_quadrangulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def stratum_component(self):
H_2(2)^hyp
sage: q = VeeringQuadrangulation("(0,1,2,3,4)", "(0)(1,2)(3,4)")
sage: component = q.stratum_component() # optional - surface_dynamics # random output due to deprecation warnings from surface dynamics
sage: component
sage: component # optional - surface_dynamics
H_3(4)^odd
"""
return self.to_origami().stratum_component()
Expand Down
10 changes: 0 additions & 10 deletions veerer/veering_triangulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,6 @@ def as_linear_family(self, mutable=False):
sage: vt.as_linear_family()
VeeringTriangulationLinearFamily("(0,1,2)(~2,~0,~1)", "RRB", [(1, 0, -1), (0, 1, 1)])
"""
require_package('sage', 'as_linear_family')

from .linear_family import VeeringTriangulationLinearFamily
P = self.train_track_linear_space()
return VeeringTriangulationLinearFamily(self, self.train_track_linear_space().lines(), mutable=mutable)
Expand Down Expand Up @@ -3012,8 +3010,6 @@ def _complexify_generators(self, Gx):
sage: T._set_switch_conditions(T._tt_check, Gy.row(0), HORIZONTAL)
sage: T._set_switch_conditions(T._tt_check, Gy.row(1), HORIZONTAL)
"""
require_package('sage', '_complexify_generators')

ne = self.num_edges()
ep = self._ep
if Gx.ncols() != ne:
Expand Down Expand Up @@ -3054,8 +3050,6 @@ def _complexify_equations(self, Lx):
sage: V2 = V.subspace(Gy.right_kernel_matrix())
sage: assert V1 == V2
"""
require_package('sage', '_complexify_equations')

ne = self.num_edges()
ep = self._ep
if Lx.ncols() != ne:
Expand All @@ -3074,8 +3068,6 @@ def _flat_structure_from_train_track_lengths(self, VH, VV, base_ring=None, mutab
Return a flat structure from two vectors ``VH`` and ``VV``
satisfying the train track equations.
"""
require_package('sage', '_flat_structure_from_train_track_lengths')

from sage.modules.free_module import VectorSpace

if base_ring is None:
Expand Down Expand Up @@ -3180,8 +3172,6 @@ def flat_structure_min(self, allow_degenerations=False):
sage: F.to_veering_triangulation() # optional - surface_dynamics
VeeringTriangulation("(0,18,~17)(1,20,~19)...(19,~18,~0)", "RRRRRRRRBBBBBBBBBGBBBBBP")
"""
require_package('sage', 'flat_structure_min')

VH = self.train_track_min_solution(HORIZONTAL, allow_degenerations=allow_degenerations)
VV = self.train_track_min_solution(VERTICAL, allow_degenerations=allow_degenerations)

Expand Down
Loading