From 8a20d4cd4c413b40ff7685e6b2d363155b91a7d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20R=C3=BCth?= Date: Thu, 9 Nov 2023 13:57:42 +0200 Subject: [PATCH 1/7] Run tests without SageMath --- .github/workflows/test.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 066db86..b9e7527 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,6 +34,15 @@ jobs: - optionals: "sage,sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" sagelib: "10.0" python: "3.10.5" + - optionals: "flipper" + python: "3.10.5" + # Test with the latest versions of Python but without SageMath + - optionals: "flipper" + python: "3.10.13" + - optionals: "flipper" + python: "3.11.6" + - optionals: "flipper" + python: "3.12.0" steps: - uses: actions/checkout@v2 with: { submodules: recursive } @@ -42,8 +51,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 From dcda2032da57b32a95f84b5c78c472ed190f5783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20R=C3=BCth?= Date: Thu, 9 Nov 2023 13:59:48 +0200 Subject: [PATCH 2/7] Do not install sagelib if we are not testing with SageMath installed --- environment.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/environment.yml b/environment.yml index 04e612f..70e3d96 100644 --- a/environment.yml +++ b/environment.yml @@ -13,8 +13,8 @@ dependencies: - matplotlib-base - gap-defaults - sympy - - sagemath-db-conway-polynomials - - sagelib >=9.3 + - sagemath-db-conway-polynomials # optional: sage + - sagelib >=9.3 # optional: sage # some of the tests rely on ipywidgets which is not required by sagelib - ipywidgets # Work around https://github.com/conda-forge/givaro-feedstock/issues/13 From d27128f62d47c1d5584eff10e3a8f7d4e566a277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20R=C3=BCth?= Date: Thu, 9 Nov 2023 14:02:43 +0200 Subject: [PATCH 3/7] We need Cython when SageMath does not pull it in implicitly --- environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/environment.yml b/environment.yml index 70e3d96..9b0a374 100644 --- a/environment.yml +++ b/environment.yml @@ -6,6 +6,7 @@ name: veerer-build channels: - conda-forge dependencies: + - cython - pytest - pytest-xdist - ipywidgets From 615e5630583daed80d476c2c4e419c343cac2252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20R=C3=BCth?= Date: Mon, 13 Nov 2023 22:25:45 +0200 Subject: [PATCH 4/7] Require sagelib to be installed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit we concluded that it's unrealistic that somebody needs this package without being able to install SageMath. The effort to maintain such a package is too high for such an unlikely use case (it's essentially Windows users…) --- .github/workflows/test.yml | 38 ++++++++++++++++---------- environment.yml | 4 +-- veerer/automaton.py | 2 -- veerer/env.py | 37 +++---------------------- veerer/flip_sequence.py | 3 -- veerer/polyhedron/linear_expression.py | 3 -- veerer/triangulation.py | 1 - veerer/veering_triangulation.py | 10 ------- 8 files changed, 30 insertions(+), 68 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b9e7527..e0100e2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,36 +13,46 @@ jobs: strategy: matrix: include: - - optionals: "sage,sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" + - optionals: "sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" sagelib: "9.3" python: "3.9.2" - - optionals: "sage,sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" + - optionals: "sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" sagelib: "9.4" python: "3.9.5" - - optionals: "sage,sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" + - optionals: "sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" sagelib: "9.5" python: "3.9.9" - - optionals: "sage,sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" + - optionals: "sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" sagelib: "9.6" python: "3.10.5" - - optionals: "sage,sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" + - optionals: "sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" sagelib: "9.7" python: "3.10.5" - - optionals: "sage,sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" + - optionals: "sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" sagelib: "9.8" python: "3.10.5" - - optionals: "sage,sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" + - optionals: "sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" sagelib: "10.0" python: "3.10.5" - - optionals: "flipper" + # Test optional dependencies in isolation + - optionals: "" + sagelib: "10.0" + python: "3.10.5" + - optionals: "sage_flatsurf" + sagelib: "10.0" + python: "3.10.5" + - optionals: "pyeantic" + sagelib: "10.0" + python: "3.10.5" + - optionals: "pyintervalxt" + sagelib: "10.0" + python: "3.10.5" + - optionals: "surface_dynamics" + sagelib: "10.0" python: "3.10.5" - # Test with the latest versions of Python but without SageMath - - optionals: "flipper" - python: "3.10.13" - - optionals: "flipper" - python: "3.11.6" - optionals: "flipper" - python: "3.12.0" + sagelib: "10.0" + python: "3.10.5" steps: - uses: actions/checkout@v2 with: { submodules: recursive } diff --git a/environment.yml b/environment.yml index 9b0a374..f5265aa 100644 --- a/environment.yml +++ b/environment.yml @@ -14,8 +14,8 @@ dependencies: - matplotlib-base - gap-defaults - sympy - - sagemath-db-conway-polynomials # optional: sage - - sagelib >=9.3 # optional: sage + - sagemath-db-conway-polynomials + - sagelib >=9.3 # some of the tests rely on ipywidgets which is not required by sagelib - ipywidgets # Work around https://github.com/conda-forge/givaro-feedstock/issues/13 diff --git a/veerer/automaton.py b/veerer/automaton.py index 21f46f2..770d991 100644 --- a/veerer/automaton.py +++ b/veerer/automaton.py @@ -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) diff --git a/veerer/env.py b/veerer/env.py index d7ce836..755cb9c 100644 --- a/veerer/env.py +++ b/veerer/env.py @@ -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: @@ -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', @@ -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, diff --git a/veerer/flip_sequence.py b/veerer/flip_sequence.py index e6dec71..a2d75a2 100644 --- a/veerer/flip_sequence.py +++ b/veerer/flip_sequence.py @@ -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()) @@ -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()) @@ -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 diff --git a/veerer/polyhedron/linear_expression.py b/veerer/polyhedron/linear_expression.py index 2649e93..348b5a7 100644 --- a/veerer/polyhedron/linear_expression.py +++ b/veerer/polyhedron/linear_expression.py @@ -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 @@ -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) diff --git a/veerer/triangulation.py b/veerer/triangulation.py index 82f980c..001c4ae 100644 --- a/veerer/triangulation.py +++ b/veerer/triangulation.py @@ -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 diff --git a/veerer/veering_triangulation.py b/veerer/veering_triangulation.py index 017f3ec..397ba08 100644 --- a/veerer/veering_triangulation.py +++ b/veerer/veering_triangulation.py @@ -268,8 +268,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) @@ -2974,8 +2972,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: @@ -3016,8 +3012,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: @@ -3036,8 +3030,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: @@ -3142,8 +3134,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) From 886858aec7425695af4ff09b7c52945045e42c69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20R=C3=BCth?= Date: Mon, 13 Nov 2023 22:33:33 +0200 Subject: [PATCH 5/7] Always run sage: doctests --- .github/workflows/test.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e0100e2..43da4c6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,44 +13,44 @@ jobs: strategy: matrix: include: - - optionals: "sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" + - optionals: "sage,sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" sagelib: "9.3" python: "3.9.2" - - optionals: "sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" + - optionals: "sage,sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" sagelib: "9.4" python: "3.9.5" - - optionals: "sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" + - optionals: "sage,sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" sagelib: "9.5" python: "3.9.9" - - optionals: "sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" + - optionals: "sage,sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" sagelib: "9.6" python: "3.10.5" - - optionals: "sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" + - optionals: "sage,sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" sagelib: "9.7" python: "3.10.5" - - optionals: "sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" + - optionals: "sage,sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" sagelib: "9.8" python: "3.10.5" - - optionals: "sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" + - optionals: "sage,sage_flatsurf,pyeantic,pyintervalxt,surface_dynamics,flipper" sagelib: "10.0" python: "3.10.5" # Test optional dependencies in isolation - - optionals: "" + - optionals: "sage" sagelib: "10.0" python: "3.10.5" - - optionals: "sage_flatsurf" + - optionals: "sage,sage_flatsurf" sagelib: "10.0" python: "3.10.5" - - optionals: "pyeantic" + - optionals: "sage,pyeantic" sagelib: "10.0" python: "3.10.5" - - optionals: "pyintervalxt" + - optionals: "sage,pyintervalxt" sagelib: "10.0" python: "3.10.5" - - optionals: "surface_dynamics" + - optionals: "sage,surface_dynamics" sagelib: "10.0" python: "3.10.5" - - optionals: "flipper" + - optionals: "sage,flipper" sagelib: "10.0" python: "3.10.5" steps: From 107e1501acff1cd7757319e5ce263351af241ce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20R=C3=BCth?= Date: Mon, 13 Nov 2023 22:45:28 +0200 Subject: [PATCH 6/7] Add missing optional marker --- veerer/veering_quadrangulation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/veerer/veering_quadrangulation.py b/veerer/veering_quadrangulation.py index 4c4fa90..0d80afb 100644 --- a/veerer/veering_quadrangulation.py +++ b/veerer/veering_quadrangulation.py @@ -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() From 754fed23588e8a22b5c2feb779e23b363ee48861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20R=C3=BCth?= Date: Mon, 13 Nov 2023 22:57:52 +0200 Subject: [PATCH 7/7] Update README --- README.rst | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index f17e6d4..4c3a3a7 100644 --- a/README.rst +++ b/README.rst @@ -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 `_ 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 `_. -To install this package you only need Python but additional features are -available if this package is used inside `SageMath -`_. - -Computations involving polytopes are only available if the Python package -`pplpy `_ is available. It is installed -by default with SageMath, version 8.7 or above. - Example -------