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

Commit

Permalink
Merge #32866
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Nov 16, 2021
2 parents b8f0a10 + 944bb74 commit 2463e1e
Showing 1 changed file with 90 additions and 1 deletion.
91 changes: 90 additions & 1 deletion src/sage/features/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

class InterfaceFeature(Feature):
r"""
A :class:`Feature` describing whether an :class:`~sage.interfaces.interface.Interface` is present and functional.
TESTS::
sage: from sage.features.interfaces import InterfaceFeature
Expand All @@ -25,15 +27,41 @@ class InterfaceFeature(Feature):
"""
@staticmethod
def __classcall__(cls, name, module, description=None):
"""
TESTS::
sage: from sage.features import PythonModule
sage: from sage.features.interfaces import InterfaceFeature
sage: f = InterfaceFeature("test_interface", "sage.interfaces.interface")
sage: f is InterfaceFeature("test_interface", PythonModule("sage.interfaces.interface"))
True
"""
if isinstance(module, str):
module = PythonModule(module)
return Feature.__classcall__(cls, name, module, description)

def __init__(self, name, module, description):
"""
TESTS::
sage: from sage.features.interfaces import InterfaceFeature
sage: f = InterfaceFeature("test_interface", "sage.interfaces.interface")
sage: isinstance(f, InterfaceFeature)
True
"""
super().__init__(name, description=description)
self.module = module

def _is_present(self):
"""
TESTS::
sage: from sage.features.interfaces import InterfaceFeature
sage: from sage.interfaces.sage0 import Sage
sage: f = InterfaceFeature("sage0", "sage.interfaces.sage0")
sage: f.is_present()
FeatureTestResult('sage0', True)
"""
result = self.module.is_present()
if not result:
return result
Expand All @@ -50,6 +78,7 @@ def _is_present(self):
return FeatureTestResult(self, False,
reason=f"Interface {interface} is not functional: {exception}")


# The following are provided by external software only (no SPKG)

class Magma(InterfaceFeature):
Expand All @@ -61,7 +90,7 @@ class Magma(InterfaceFeature):
sage: from sage.features.interfaces import Magma
sage: Magma().is_present() # random
FeatureTestResult('jupymake', False)
FeatureTestResult('magma', False)
"""

@staticmethod
Expand All @@ -70,41 +99,101 @@ def __classcall__(cls):


class Matlab(InterfaceFeature):
r"""
A :class:`sage.features.Feature` describing whether :class:`sage.interfaces.matlab.Matlab`
is present and functional.
EXAMPLES::
sage: from sage.features.interfaces import Matlab
sage: Matlab().is_present() # random
FeatureTestResult('matlab', False)
"""

@staticmethod
def __classcall__(cls):
return InterfaceFeature.__classcall__(cls, 'matlab', 'sage.interfaces.matlab')


class Mathematica(InterfaceFeature):
r"""
A :class:`sage.features.Feature` describing whether :class:`sage.interfaces.mathematica.Mathematica`
is present and functional.
EXAMPLES::
sage: from sage.features.interfaces import Mathematica
sage: Mathematica().is_present() # random
FeatureTestResult('mathematica', False)
"""

@staticmethod
def __classcall__(cls):
return InterfaceFeature.__classcall__(cls, 'mathematica', 'sage.interfaces.mathematica')


class Maple(InterfaceFeature):
r"""
A :class:`sage.features.Feature` describing whether :class:`sage.interfaces.maple.Maple`
is present and functional.
EXAMPLES::
sage: from sage.features.interfaces import Maple
sage: Maple().is_present() # random
FeatureTestResult('maple', False)
"""

@staticmethod
def __classcall__(cls):
return InterfaceFeature.__classcall__(cls, 'maple', 'sage.interfaces.maple')


class Macaulay2(InterfaceFeature):
r"""
A :class:`sage.features.Feature` describing whether :class:`sage.interfaces.macaulay2.Macaulay2`
is present and functional.
EXAMPLES::
sage: from sage.features.interfaces import Macaulay2
sage: Macaulay2().is_present() # random
FeatureTestResult('macaulay2', False)
"""

@staticmethod
def __classcall__(cls):
return InterfaceFeature.__classcall__(cls, 'macaulay2', 'sage.interfaces.macaulay2')


class Octave(InterfaceFeature):
r"""
A :class:`sage.features.Feature` describing whether :class:`sage.interfaces.octave.Octave`
is present and functional.
EXAMPLES::
sage: from sage.features.interfaces import Octave
sage: Octave().is_present() # random
FeatureTestResult('octave', False)
"""

@staticmethod
def __classcall__(cls):
return InterfaceFeature.__classcall__(cls, 'octave', 'sage.interfaces.octave')


class Scilab(InterfaceFeature):
r"""
A :class:`sage.features.Feature` describing whether :class:`sage.interfaces.scilab.Scilab`
is present and functional.
EXAMPLES::
sage: from sage.features.interfaces import Scilab
sage: Scilab().is_present() # random
FeatureTestResult('scilab', False)
"""

@staticmethod
def __classcall__(cls):
Expand Down

0 comments on commit 2463e1e

Please sign in to comment.