#17130: Coercion after _eval_() in symbolic functions
-----------------------------+------------------------
       Reporter:  jdemeyer   |        Owner:
           Type:  defect     |       Status:  new
       Priority:  major      |    Milestone:  sage-6.4
      Component:  symbolics  |   Resolution:
       Keywords:             |    Merged in:
        Authors:             |    Reviewers:
Report Upstream:  N/A        |  Work issues:
         Branch:             |       Commit:
   Dependencies:             |     Stopgaps:
-----------------------------+------------------------

Comment (by jdemeyer):

 The following patch fixes the problem
 {{{
 #!diff
 diff --git a/src/sage/symbolic/function.pyx
 b/src/sage/symbolic/function.pyx
 index 408b6da..5beb01d 100644
 --- a/src/sage/symbolic/function.pyx
 +++ b/src/sage/symbolic/function.pyx
 @@ -914,38 +914,6 @@ cdef class BuiltinFunction(Function):
          res = super(BuiltinFunction, self).__call__(
                          *args, coerce=coerce, hold=hold)

 -        # we want to convert the result to the original parent if the
 input
 -        # is not exact, so we store the parent here
 -        org_parent = parent_c(args[0])
 -
 -        # convert the result back to the original parent previously
 stored
 -        # otherwise we end up with
 -        #     sage: arctan(RR(1))
 -        #     1/4*pi
 -        # which is surprising, to say the least...
 -        if org_parent is not SR and \
 -                (org_parent is float or org_parent is complex or \
 -                (PY_TYPE_CHECK(org_parent, Parent) and \
 -                    not org_parent.is_exact())):
 -            try:
 -                return org_parent(res)
 -            except (TypeError, ValueError):
 -                pass
 -
 -            # conversion to the original parent failed
 -            # we try if it works with the corresponding complex domain
 -            if org_parent is float or org_parent is complex:
 -                try:
 -                    from sage.rings.complex_double import CDF
 -                    return complex(CDF(res))
 -                except (TypeError, ValueError):
 -                    pass
 -            elif hasattr(org_parent, 'complex_field'):
 -                try:
 -                    return org_parent.complex_field()(res)
 -                except (TypeError, ValueError):
 -                    pass
 -
          return res

      cdef _is_registered(self):
 }}}
 but with quite a bit of doctest failures.

--
Ticket URL: <http://trac.sagemath.org/ticket/17130#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to