예제 #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
예제 #2
0
파일: constants.py 프로젝트: mcognetta/sage
    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
예제 #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)