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

Commit 73ad696

Browse files
author
Matthias Koeppe
committed
src/sage/features/interfaces.py: Add FriCASExecutable, FriCAS
1 parent 55a711e commit 73ad696

File tree

2 files changed

+46
-8
lines changed

2 files changed

+46
-8
lines changed

src/sage/features/interfaces.py

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
import importlib
55

6-
from . import Feature, FeatureTestResult, PythonModule
6+
from . import Executable, Feature, FeatureTestResult, PythonModule
77

88

99
class InterfaceFeature(Feature):
@@ -26,7 +26,7 @@ class InterfaceFeature(Feature):
2626
"Interface also_broken_interface cannot be imported: module 'sage.interfaces.interface' has no attribute 'also_broken_interface'"
2727
"""
2828
@staticmethod
29-
def __classcall__(cls, name, module, description=None):
29+
def __classcall__(cls, name, module, description=None, **kwds):
3030
"""
3131
TESTS::
3232
@@ -38,9 +38,9 @@ def __classcall__(cls, name, module, description=None):
3838
"""
3939
if isinstance(module, str):
4040
module = PythonModule(module)
41-
return Feature.__classcall__(cls, name, module, description)
41+
return Feature.__classcall__(cls, name, module, description, **kwds)
4242

43-
def __init__(self, name, module, description):
43+
def __init__(self, name, module, description, **kwds):
4444
"""
4545
TESTS::
4646
@@ -49,7 +49,7 @@ def __init__(self, name, module, description):
4949
sage: isinstance(f, InterfaceFeature)
5050
True
5151
"""
52-
super().__init__(name, description=description)
52+
super().__init__(name, description=description, **kwds)
5353
self.module = module
5454

5555
def _is_present(self):
@@ -79,6 +79,38 @@ def _is_present(self):
7979
reason=f"Interface {interface} is not functional: {exception}")
8080

8181

82+
class FriCASExecutable(Executable):
83+
r"""
84+
A :class:`~sage.features.Feature` describing whether :class:`sage.interfaces.fricas.FriCAS`
85+
is present and functional.
86+
87+
EXAMPLES::
88+
89+
sage: from sage.features.interfaces import FriCASExecutable
90+
sage: FriCASExecutable().is_present() # random
91+
FeatureTestResult('fricas_exe', False)
92+
"""
93+
@staticmethod
94+
def __classcall__(cls):
95+
return Executable.__classcall__(cls, 'fricas_exe', 'fricas', spkg='fricas')
96+
97+
98+
class FriCAS(InterfaceFeature):
99+
r"""
100+
A :class:`~sage.features.Feature` describing whether :class:`sage.interfaces.fricas.FriCAS`
101+
is present and functional.
102+
103+
EXAMPLES::
104+
105+
sage: from sage.features.interfaces import FriCAS
106+
sage: FriCAS().is_present() # random
107+
FeatureTestResult('fricas', False)
108+
"""
109+
@staticmethod
110+
def __classcall__(cls):
111+
return InterfaceFeature.__classcall__(cls, 'fricas', 'sage.interfaces.fricas', spkg='fricas')
112+
113+
82114
# The following are provided by external software only (no SPKG)
83115

84116
class Magma(InterfaceFeature):
@@ -208,15 +240,17 @@ def all_features():
208240
209241
sage: from sage.features.interfaces import all_features
210242
sage: list(all_features())
211-
[Feature('magma'),
243+
[Feature('fricas'),
244+
Feature('magma'),
212245
Feature('matlab'),
213246
Feature('mathematica'),
214247
Feature('maple'),
215248
Feature('macaulay2'),
216249
Feature('octave'),
217250
Feature('scilab')]
218251
"""
219-
return [Magma(),
252+
return [FriCAS(),
253+
Magma(),
220254
Matlab(),
221255
Mathematica(),
222256
Maple(),

src/sage/interfaces/fricas.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ class FriCAS(ExtraTabCompletion, Expect):
261261
"""
262262
Interface to a FriCAS interpreter.
263263
"""
264-
def __init__(self, name='fricas', command='fricas -nosman',
264+
def __init__(self, name='fricas', command=None,
265265
script_subdirectory=None, logfile=None,
266266
server=None, server_tmpdir=None):
267267
"""
@@ -286,6 +286,10 @@ def __init__(self, name='fricas', command='fricas -nosman',
286286
sage: fricas(I*x).sage() # optional - fricas
287287
I*x
288288
"""
289+
if command is None:
290+
from sage.features.interfaces import FriCASExecutable
291+
fricas_exe = FriCASExecutable().absolute_filename()
292+
command = f'{fricas_exe} -nosman'
289293
eval_using_file_cutoff = 4096 - 5 # magic number from Expect._eval_line (there might be a bug)
290294
assert max(len(c) for c in FRICAS_INIT_CODE) < eval_using_file_cutoff
291295
self.__eval_using_file_cutoff = eval_using_file_cutoff

0 commit comments

Comments
 (0)