sagemath/sage

sage.features.lrs: Make it a JoinFeature of Lrs, LrsNash; use Executable.absolute_filename

mkoeppe opened this issue · 18 comments

... as suggested in #33167 comment:4

Then use Lrs().absolute_filename()
and LrsNash().absolute_filename() (see #31296).

This makes these parts of the Sage library fully functional even when not being run from within sage-env (which sets PATH). To test this on a system without system lrslib installed, after sage -i lrslib:

$ venv/bin/python3 -c 'from sage.all import *; print(polytopes.hypercube(3).volume(engine="lrs"))'
$ venv/bin/python3 -c 'from sage.all import *; A = matrix([[1, -1], [-1, 1]]); B = matrix([[-1, 1], [1, -1]]); matching_pennies = NormalFormGame([A, B]); print(matching_pennies.obtain_nash(algorithm="lrs"))'

Depends on #31296

CC: @mwageringel @seblabbe @dimpase @saraedum @dcoudert @kliem

Component: refactoring

Author: Matthias Koeppe

Branch/Commit: b65f6a6

Reviewer: Sébastien Labbé

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

Dependencies: #31296

Commit: 2c58bc2

Description changed:

--- 
+++ 
@@ -1,4 +1,5 @@
 ... as suggested in [#33167 comment:4](https://github.com/sagemath/sage/issues/33167#comment:4)
 
-Then use `LrsNash().absolute_pathname()` (see #31296).
+Then use `Lrs().absolute_pathname()` 
+ and `LrsNash().absolute_pathname()` (see #31296).
 

Last 10 new commits:

9fad95eMerge #31292
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
5145cb3Merge #31296
2c58bc2src/sage/features/lrs.py: Make Lrslib a JoinFeature of Lrs and LrsNash, use Executable.absolute_filename

Description changed:

--- 
+++ 
@@ -3,3 +3,11 @@
 Then use `Lrs().absolute_pathname()` 
  and `LrsNash().absolute_pathname()` (see #31296).
 
+This makes these parts of the Sage library fully functional even when not being run from within sage-env (which sets `PATH`). To test this on a system without system lrslib installed, after `sage -i lrslib`:
+
+```
+$ venv/bin/python3 -c 'from sage.all import *; print(polytopes.hypercube(3).volume(engine="lrs"))'
+$ venv/bin/python3 -c 'from sage.all import *; A = matrix([[1, -1], [-1, 1]]); B = matrix([[-1, 1], [1, -1]]); matching_pennies = NormalFormGame([A, B]); print(matching_pennies.obtain_nash(algorithm="lrs"))'
+```
+
+

Branch pushed to git repo; I updated commit sha1. New commits:

88bef23sage.game_theory: Use LrsNash().absolute_filename()
b1360f7Polyhedron_base._volume_lrs: Use Lrs().absolute_filename()
ec9bf39src/sage/game_theory/normal_form_game.py: Fix import

Changed commit from 2c58bc2 to ec9bf39

Author: Matthias Koeppe

Description changed:

--- 
+++ 
@@ -1,7 +1,7 @@
 ... as suggested in [#33167 comment:4](https://github.com/sagemath/sage/issues/33167#comment:4)
 
-Then use `Lrs().absolute_pathname()` 
- and `LrsNash().absolute_pathname()` (see #31296).
+Then use `Lrs().absolute_filename()` 
+ and `LrsNash().absolute_filename()` (see #31296).
 
 This makes these parts of the Sage library fully functional even when not being run from within sage-env (which sets `PATH`). To test this on a system without system lrslib installed, after `sage -i lrslib`:
 

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

58d1186src/sage/features/lrs.py: Make Lrslib a JoinFeature of Lrs and LrsNash, use Executable.absolute_filename
1b90dd9sage.game_theory: Use LrsNash().absolute_filename()
e244564Polyhedron_base._volume_lrs: Use Lrs().absolute_filename()
b65f6a6src/sage/game_theory/normal_form_game.py: Fix import

Changed commit from ec9bf39 to b65f6a6

comment:12

Rebased

Reviewer: Sébastien Labbé

comment:13

All tests pass for me for the modified files with and without optional package lrslib. Patchbot is green.

comment:14

Also, here is what I get:

$ venv/bin/python3 -c 'from sage.all import *; print(polytopes.hypercube(3).volume(engine="lrs"))'
8
$ venv/bin/python3 -c 'from sage.all import *; A = matrix([[1, -1], [-1, 1]]); B = matrix([[-1, 1], [1, -1]]); matching_pennies = NormalFormGame([A, B]); print(matching_pennies.obtain_nash(algorithm="lrs"))'
[[(1/2, 1/2), (1/2, 1/2)]]
comment:15

Thank you!