Skip to content

Commit

Permalink
Trac #32893: Features for palp, polytopes_db, polytopes_db_4d
Browse files Browse the repository at this point in the history
`palp` is a standard package, but with modularization that does not mean
that everyone has it. In particular, '''sagemath-polyhedra''' (#32432)
will not ship it.

We add a feature test along the lines of the palp `spkg-configure.m4`
script and mark many doctests in `sage.geometry` as `# optional - palp`.

To help construct doctest examples without having to rely on `palp`, we
endow several classes with `_sage_input_` methods.

As a cosmetic change, nef-partitions now use a unicode symbol.
{{{
-            Nef-partition {0, 1, 3} U {2, 4, 5}
+            Nef-partition {0, 1, 3} ⊔ {2, 4, 5}
}}}

We also add feature tests for `polytopes_db`, `polytopes_db_4d`.

URL: https://trac.sagemath.org/32893
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): Dima Pasechnik
  • Loading branch information
Release Manager committed Mar 8, 2022
2 parents ed49c68 + d97479d commit 950ecf8
Show file tree
Hide file tree
Showing 17 changed files with 663 additions and 495 deletions.
32 changes: 30 additions & 2 deletions src/sage/features/databases.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from . import StaticFile, PythonModule
from sage.env import (
CONWAY_POLYNOMIALS_DATA_DIR,
CREMONA_MINI_DATA_DIR, CREMONA_LARGE_DATA_DIR)
CREMONA_MINI_DATA_DIR, CREMONA_LARGE_DATA_DIR,
POLYTOPE_DATA_DIR)


class DatabaseConwayPolynomials(StaticFile):
Expand Down Expand Up @@ -127,8 +128,35 @@ def __init__(self):
PythonModule.__init__(self, 'database_knotinfo', spkg='database_knotinfo')


class DatabaseReflexivePolytopes(StaticFile):
r"""
A :class:`~sage.features.Feature` which describes the presence of the PALP database
of reflexive lattice polytopes.
EXAMPLES::
sage: from sage.features.databases import DatabaseReflexivePolytopes
sage: bool(DatabaseReflexivePolytopes().is_present()) # optional - polytopes_db
True
sage: bool(DatabaseReflexivePolytopes('polytopes_db_4d', 'Hodge4d').is_present()) # optional - polytopes_db_4d
True
"""
def __init__(self, name='polytopes_db', dirname='Full3D'):
"""
TESTS::
sage: from sage.features.databases import DatabaseReflexivePolytopes
sage: isinstance(DatabaseReflexivePolytopes(), DatabaseReflexivePolytopes)
True
"""
StaticFile.__init__(self, name, dirname,
search_path=[POLYTOPE_DATA_DIR])


def all_features():
return [DatabaseConwayPolynomials(),
DatabaseCremona(), DatabaseCremona('cremona_mini'),
DatabaseJones(),
DatabaseKnotInfo()]
DatabaseKnotInfo(),
DatabaseReflexivePolytopes(),
DatabaseReflexivePolytopes('polytopes_db_4d', 'Hodge4d')]
64 changes: 64 additions & 0 deletions src/sage/features/palp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
r"""
Feature for testing the presence of ``palp``
"""
# ****************************************************************************
# Copyright (C) 2022 Matthias Koeppe
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# https://www.gnu.org/licenses/
# ****************************************************************************

from . import Executable
from .join_feature import JoinFeature


class PalpExecutable(Executable):
r"""
A :class:`~sage.features.Feature` describing the presence of a PALP executable.
INPUT:
- ``palpprog`` -- string, one of "poly", "class", "nef", "cws".
- ``suff`` -- string or ``None``.
"""
def __init__(self, palpprog, suff=None):
r"""
TESTS::
sage: from sage.features.palp import PalpExecutable
sage: isinstance(PalpExecutable("poly", 5), PalpExecutable)
True
"""
if suff:
Executable.__init__(self, f"palp_{palpprog}_{suff}d",
executable=f"{palpprog}-{suff}d.x",
spkg="palp")
else:
Executable.__init__(self, f"palp_{palpprog}",
executable=f"{palpprog}.x",
spkg="palp")

class Palp(JoinFeature):
r"""
A :class:`~sage.features.Feature` describing the presence of ``PALP``.
"""
def __init__(self):
r"""
TESTS::
sage: from sage.features.palp import Palp
sage: isinstance(Palp(), Palp)
True
"""
JoinFeature.__init__(self, "palp",
[PalpExecutable(palpprog, suff)
for palpprog in ("poly", "class", "nef", "cws")
for suff in (None, 4, 5, 6, 11)],
description="PALP")

def all_features():
return [Palp()]
9 changes: 4 additions & 5 deletions src/sage/geometry/cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -2745,17 +2745,16 @@ def faces(self, dim=None, codim=None):
We also ensure that a call to this function does not break
:meth:`facets` method (see :trac:`9780`)::
sage: cone = toric_varieties.dP8().fan().generating_cone(0)
sage: cone
sage: cone = toric_varieties.dP8().fan().generating_cone(0); cone # optional - palp
2-d cone of Rational polyhedral fan in 2-d lattice N
sage: for f in cone.facets(): print(f.rays())
sage: for f in cone.facets(): print(f.rays()) # optional - palp
N(1, 1)
in 2-d lattice N
N(0, 1)
in 2-d lattice N
sage: len(cone.faces())
sage: len(cone.faces()) # optional - palp
3
sage: for f in cone.facets(): print(f.rays())
sage: for f in cone.facets(): print(f.rays()) # optional - palp
N(1, 1)
in 2-d lattice N
N(0, 1)
Expand Down
Loading

0 comments on commit 950ecf8

Please sign in to comment.