Beispiel #1
0
    def _interface_(self, I):
        """
        EXAMPLES::

            sage: from sage.symbolic.constants import Constant
            sage: p = Constant('p', conversions=dict(maxima='%pi'))
            sage: p._interface_(maxima)
            %pi
        """
        try:
            s = self._conversions[I.name()]
            return I(s)
        except KeyError:
            pass

        try:
            return getattr(self, "_%s_" % (I.name()))(I)
        except AttributeError:
            pass

        raise NotImplementedError
Beispiel #2
0
    def _interface_(self, I):
        """
        EXAMPLES::

            sage: from sage.symbolic.constants import Constant
            sage: p = Constant('p', conversions=dict(maxima='%pi'))
            sage: p._interface_(maxima)
            %pi
        """
        try:
            s = self._conversions[I.name()]
            return I(s)
        except KeyError:
            pass
        
        try:
            return getattr(self, "_%s_"%(I.name()))(I)
        except AttributeError:
            pass

        raise NotImplementedError
Beispiel #3
0
    def _generic_interface(self, value, I):
        """
        This is a helper method used in defining the ``_X_`` methods
        where ``X`` is the name of some interface.

        EXAMPLES::

            sage: from sage.symbolic.constants import Constant
            sage: p = Constant('p', conversions=dict(maxima='%pi'))
            sage: p._maxima_(maxima)
            %pi

        The above ``_maxima_`` is constructed like ``m`` below::

            sage: from functools import partial
            sage: m = partial(p._generic_interface, '%pi')
            sage: m(maxima)
            %pi

        """
        return I(value)