Ticket #13608: trac13608-workaround.patch

File trac13608-workaround.patch, 1.8 KB (added by Dan Drake, 10 years ago)

fix trailing whitespace, make patchbot happy

  • sage/functions/log.py

    # HG changeset patch
    # User Dan Drake <ddrake@member.ams.org>
    # Date 1350415974 25200
    # Node ID 3a1bf4faf0e26a8b194dd20c1f5e04e35d52b3b9
    # Parent  c95c1ffa8aff73e6055bf82919815d93bf66d1a8
    allow top-level exp() to work with mpmath mpf numbers
    
    diff --git a/sage/functions/log.py b/sage/functions/log.py
    a b  
    125125            doctest:...: DeprecationWarning: The prec keyword argument is deprecated. Explicitly set the precision of the input, for example exp(RealField(300)(1)), or use the prec argument to .n() for exact inputs, e.g., exp(1).n(300), instead.
    126126            See http://trac.sagemath.org/7490 for details.
    127127            7.3890560989306502272304274606
     128
     129        Ensure that :trac:`13608` is fixed::
     130
     131            sage: import mpmath
     132            sage: exp(mpmath.mpf('0.5'))
     133            mpf('1.6487212707001282')
    128134        """
    129135        if prec is not None:
    130136            from sage.misc.superseded import deprecation
     
    132138            x = GinacFunction.__call__(self, x, coerce=coerce, hold=hold,
    133139                    dont_call_method_on_arg=dont_call_method_on_arg)
    134140            return x.n(prec)
    135         return GinacFunction.__call__(self, x, coerce=coerce, hold=hold,
    136                 dont_call_method_on_arg=dont_call_method_on_arg)
     141        try:
     142            return GinacFunction.__call__(self, x, coerce=coerce, hold=hold,
     143                    dont_call_method_on_arg=dont_call_method_on_arg)
     144        except TypeError:
     145            # mpmath floats have a .exp attribute, but it's not the
     146            # exponential function. See #13608.
     147            from mpmath import mpf
     148            if type(x) == mpf:
     149                from mpmath import exp as mpmath_exp
     150                return mpmath_exp(x)
     151            else:
     152                raise
    137153
    138154exp = Function_exp()
    139155