Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 2c58bc2

Browse files
author
Matthias Koeppe
committed
src/sage/features/lrs.py: Make Lrslib a JoinFeature of Lrs and LrsNash, use Executable.absolute_filename
1 parent 5145cb3 commit 2c58bc2

File tree

1 file changed

+67
-8
lines changed

1 file changed

+67
-8
lines changed

src/sage/features/lrs.py

+67-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import subprocess
77

88
from . import Executable, FeatureTestResult
9+
from .join_feature import JoinFeature
910

1011

1112
class Lrs(Executable):
@@ -17,7 +18,7 @@ class Lrs(Executable):
1718
1819
sage: from sage.features.lrs import Lrs
1920
sage: Lrs().is_present() # optional - lrslib
20-
FeatureTestResult('lrslib', True)
21+
FeatureTestResult('lrs', True)
2122
"""
2223
def __init__(self):
2324
r"""
@@ -27,7 +28,7 @@ def __init__(self):
2728
sage: isinstance(Lrs(), Lrs)
2829
True
2930
"""
30-
Executable.__init__(self, "lrslib", executable="lrs", spkg="lrslib",
31+
Executable.__init__(self, "lrs", executable="lrs", spkg="lrslib",
3132
url="http://cgm.cs.mcgill.ca/~avis/C/lrs.html")
3233

3334
def is_functional(self):
@@ -38,15 +39,14 @@ def is_functional(self):
3839
3940
sage: from sage.features.lrs import Lrs
4041
sage: Lrs().is_functional() # optional - lrslib
41-
FeatureTestResult('lrslib', True)
42+
FeatureTestResult('lrs', True)
4243
"""
4344
from sage.misc.temporary_file import tmp_filename
4445

45-
# Check #1
4646
tf_name = tmp_filename()
4747
with open(tf_name, 'w') as tf:
4848
tf.write("V-representation\nbegin\n 1 1 rational\n 1 \nend\nvolume")
49-
command = ['lrs', tf_name]
49+
command = [self.absolute_filename(), tf_name]
5050
try:
5151
result = subprocess.run(command, capture_output=True, text=True)
5252
except OSError as e:
@@ -65,13 +65,49 @@ def is_functional(self):
6565
expected=" or ".join(expected_list),
6666
result=result))
6767

68-
# Check #2
68+
return FeatureTestResult(self, True)
69+
70+
71+
class LrsNash(Executable):
72+
r"""
73+
A :class:`~sage.features.Feature` describing the presence of the ``lrsnash``
74+
binary which comes as a part of ``lrslib``.
75+
76+
EXAMPLES::
77+
78+
sage: from sage.features.lrs import LrsNash
79+
sage: LrsNash().is_present() # optional - lrslib
80+
FeatureTestResult('lrsnash', True)
81+
"""
82+
def __init__(self):
83+
r"""
84+
TESTS::
85+
86+
sage: from sage.features.lrs import LrsNash
87+
sage: isinstance(LrsNash(), LrsNash)
88+
True
89+
"""
90+
Executable.__init__(self, "lrsnash", executable="lrsnash", spkg="lrslib",
91+
url="http://cgm.cs.mcgill.ca/~avis/C/lrs.html")
92+
93+
def is_functional(self):
94+
r"""
95+
Test whether ``lrsnash`` works on a trivial input.
96+
97+
EXAMPLES::
98+
99+
sage: from sage.features.lrs import LrsNash
100+
sage: LrsNash().is_functional() # optional - lrslib
101+
FeatureTestResult('lrsnash', True)
102+
"""
103+
from sage.misc.temporary_file import tmp_filename
104+
69105
# Checking whether `lrsnash` can handle the new input format
70106
# This test is currently done in build/pkgs/lrslib/spkg-configure.m4
71107
tf_name = tmp_filename()
72108
with open(tf_name, 'w') as tf:
73109
tf.write("1 1\n \n 0\n \n 0\n")
74-
command = ['lrsnash', tf_name]
110+
command = [self.absolute_filename(), tf_name]
75111
try:
76112
result = subprocess.run(command, capture_output=True, text=True)
77113
except OSError as e:
@@ -88,5 +124,28 @@ def is_functional(self):
88124
return FeatureTestResult(self, True)
89125

90126

127+
class Lrslib(JoinFeature):
128+
r"""
129+
A :class:`~sage.features.Feature` describing the presence of the executables
130+
which comes as a part of ``lrslib``.
131+
132+
EXAMPLES::
133+
134+
sage: from sage.features.lrs import Lrslib
135+
sage: Lrslib().is_present() # optional - lrslib
136+
FeatureTestResult('lrslib', True)
137+
"""
138+
def __init__(self):
139+
r"""
140+
TESTS::
141+
142+
sage: from sage.features.lrs import Lrslib
143+
sage: isinstance(Lrslib(), Lrslib)
144+
True
145+
"""
146+
JoinFeature.__init__(self, "lrslib",
147+
(Lrs(), LrsNash()))
148+
149+
91150
def all_features():
92-
return [Lrs()]
151+
return [Lrslib()]

0 commit comments

Comments
 (0)