From 944bb74f0bf0260fbc262152005745edfcdd3ad9 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Mon, 15 Nov 2021 16:13:54 -0800 Subject: [PATCH] src/sage/features/interfaces.py: Add doctests --- src/sage/features/interfaces.py | 91 ++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/src/sage/features/interfaces.py b/src/sage/features/interfaces.py index 231fba136b2..9991cfc690c 100644 --- a/src/sage/features/interfaces.py +++ b/src/sage/features/interfaces.py @@ -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 @@ -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 @@ -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): @@ -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 @@ -70,6 +99,16 @@ 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): @@ -77,6 +116,16 @@ def __classcall__(cls): 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): @@ -84,6 +133,16 @@ def __classcall__(cls): 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): @@ -91,6 +150,16 @@ def __classcall__(cls): 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): @@ -98,6 +167,16 @@ def __classcall__(cls): 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): @@ -105,6 +184,16 @@ def __classcall__(cls): 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):