sagemath/sage

sage.geometry: Use PalpExecutable(...).absolute_filename()

mkoeppe opened this issue · 15 comments

This is so that the Sage library becomes fully functional even when not being run from within sage-env (which sets PATH).

To test:

$ venv/bin/python3 -c 'from sage.all import *; print(lattice_polytope.cross_polytope(3).polar().facets()[0].ambient_point_indices())'
$ venv/bin/python3 -c 'from sage.all import *; from sage.geometry.polyhedron.palp_database import PALPreader; print(next(iter(PALPreader(2, output="list"))))'

Depends on #32893
Depends on #31296

CC: @dimpase

Component: geometry

Author: Matthias Koeppe

Branch/Commit: 4b58ad6

Reviewer: Dima Pasechnik

Issue created by migration from https://trac.sagemath.org/ticket/33467

Commit: 27b5514

Description changed:

--- 
+++ 
@@ -1 +1,9 @@
+This is so that the Sage library becomes fully functional even when not being run from within sage-env (which sets PATH).
 
+To test:
+
+```
+$ venv/bin/python3 -c 'from sage.all import *; print(lattice_polytope.cross_polytope(3).polar().facets()[0].ambient_point_indices())'
+$ venv/bin/python3 -c 'from sage.all import *; from sage.geometry.polyhedron.palp_database import PALPreader; print(next(iter(PALPreader(2, output="list"))))'
+```
+

Last 10 new commits:

a93e9afsrc/sage/features/__init__.py: Simplify Executable.absolute_path
5b25c1dsage.features: Refactor StaticFile, Executable through a new base class FileFeature
6c35717sage.features.FileFeature: Replace method absolute_path by absolute_filename, with deprecation
9266709Merge #31292
a4d0ed6sage.interfaces.four_ti_2: Use Executable.absolute_filename
4252ea3sage.sandpiles.sandpile: Use Executable.absolute_filename() when interfacing 4ti2
17b9fdesage.interfaces.latte: Use Executable.absolute_filename
d15588aMerge #31296
314ac7asrc/sage/geometry/lattice_polytope.py: Use PalpExecutable(executable).absolute_filename()
27b5514src/sage/geometry/polyhedron/palp_database.py: Use PalpExecutable(executable).absolute_filename()

Author: Matthias Koeppe

comment:3

You need to adjust doctests for latte:

File "src/sage/interfaces/latte.py", line 95, in sage.interfaces.latte.count
Failed example:
    n = count(cddin, cdd=True, verbose=True, raw_output=True)  # optional - latte_int
Expected:
    This is LattE integrale ...
    ...
    Invocation: count '--redundancy-check=none' --cdd /dev/stdin
    ...
    Total Unimodular Cones: ...
    Maximum number of simplicial cones in memory at once: ...
    <BLANKLINE>
    ****  The number of lattice points is:   ****
    Total time: ... sec
Got:
    This is LattE integrale 1.7.6
    Available from http://www.math.ucdavis.edu/~latte/
    <BLANKLINE>
    Invocation: /mnt/opt/Sage/sage-dev/local/bin/count '--redundancy-check=none' --cdd /dev/stdin 
    Warning: Not performing check for empty polytope, because it is unimplemented for the CDD-style input format. 
    size = 12 x 4
...

etc., as the path is no longer relative...

comment:4

Fix the latter is easy:

--- a/src/sage/interfaces/latte.py
+++ b/src/sage/interfaces/latte.py
@@ -95,7 +95,7 @@ def count(arg, ehrhart_polynomial=False, multivariate_generating_function=False,
         sage: n = count(cddin, cdd=True, verbose=True, raw_output=True)  # optional - latte_int
         This is LattE integrale ...
         ...
-        Invocation: count '--redundancy-check=none' --cdd /dev/stdin
+        Invocation: ...count '--redundancy-check=none' --cdd /dev/stdin
         ...
         Total Unimodular Cones: ...
         Maximum number of simplicial cones in memory at once: ...
@@ -271,7 +271,7 @@ def integrate(arg, polynomial=None, algorithm='triangulate', raw_output=False, v
         sage: ans = integrate(cddin, f, cdd=True, verbose=True, raw_output=True)  # optional - latte_int
         This is LattE integrale ...
         ...
-        Invocation: integrate --valuation=integrate --triangulate --redundancy-check=none --cdd --monomials=... /dev/stdin
+        Invocation: ...integrate --valuation=integrate --triangulate --redundancy-check=none --cdd --monomials=... /dev/stdin
         ...
 
     Testing triangulate algorithm::
@@ -313,7 +313,7 @@ def integrate(arg, polynomial=None, algorithm='triangulate', raw_output=False, v
         sage: ans = integrate(cddin, cdd=True, raw_output=True, verbose=True)  # optional - latte_int
         This is LattE integrale ...
         ...
-        Invocation: integrate --valuation=volume --triangulate --redundancy-check=none --cdd /dev/stdin
+        Invocation: ...integrate --valuation=volume --triangulate --redundancy-check=none --cdd /dev/stdin
         ...
 
     Testing the runtime error::

does this patch belong here?

Changed commit from 27b5514 to 9b1b484

Last 10 new commits:

89b24ffsrc/sage/geometry/polyhedron/palp_database.py: Add # sage.doctest: optional - palp
68babd5src/sage/geometry/lattice_polytope.py: Mark doctests # optional - palp
a1bb676src/sage/geometry: Mark doctests # optional - palp
477b84cLatticePolytopeClass, NefPartition, PointCollection, ToricLattice_ambient: Add `_sage_input_` methods
6acf7desrc/sage/geometry/lattice_polytope.py: In NefPartition doctests, construct examples without using palp
9423f26src/sage/geometry/lattice_polytope.py, src/sage/schemes/toric/fano_variety.py: Use unicode disjoint union symbol
5a220b1src/sage/geometry/lattice_polytope.py: Fix typo
c78d80esrc/sage/features/databases.py (DatabaseReflexivePolytopes): New
d6b0021src/sage/geometry/lattice_polytope.py: Use PalpExecutable(executable).absolute_filename()
9b1b484src/sage/geometry/polyhedron/palp_database.py: Use PalpExecutable(executable).absolute_filename()

Branch pushed to git repo; I updated commit sha1. This was a forced push. Last 10 new commits:

ccca4e7src/sage/geometry/polyhedron/palp_database.py: Add # sage.doctest: optional - palp
4eaad20src/sage/geometry/lattice_polytope.py: Mark doctests # optional - palp
c977daesrc/sage/geometry: Mark doctests # optional - palp
75dfdf0LatticePolytopeClass, NefPartition, PointCollection, ToricLattice_ambient: Add `_sage_input_` methods
4145202src/sage/geometry/lattice_polytope.py: In NefPartition doctests, construct examples without using palp
45edf72src/sage/geometry/lattice_polytope.py, src/sage/schemes/toric/fano_variety.py: Use unicode disjoint union symbol
bfabd53src/sage/geometry/lattice_polytope.py: Fix typo
0ac4959src/sage/features/databases.py (DatabaseReflexivePolytopes): New
bb24865src/sage/geometry/lattice_polytope.py: Use PalpExecutable(executable).absolute_filename()
4b58ad6src/sage/geometry/polyhedron/palp_database.py: Use PalpExecutable(executable).absolute_filename()

Changed commit from 9b1b484 to 4b58ad6

Reviewer: Dima Pasechnik

comment:8

Thank you!