#17953: inconsistency in returned type of BuiltinFunction result
-----------------------------+------------------------
       Reporter:  rws        |        Owner:
           Type:  defect     |       Status:  new
       Priority:  major      |    Milestone:  sage-6.6
      Component:  symbolics  |   Resolution:
       Keywords:             |    Merged in:
        Authors:             |    Reviewers:
Report Upstream:  N/A        |  Work issues:
         Branch:             |       Commit:
   Dependencies:             |     Stopgaps:
-----------------------------+------------------------
Description changed by rws:

Old description:

> It is generally preferred that the returned result type matches the
> argument type when calling a builtin function. For example this is as
> expected:
> {{{
> sage: factorial(8).parent()
> Integer Ring
> sage: factorial(SR(8)).parent()
> Symbolic Ring
> sage: exp(0).parent()
> Integer Ring
> sage: exp(SR(0)).parent()
> Symbolic Ring
> }}}
> but this is not:
> {{{
> sage: lambert_w(SR(0)).parent()
> Integer Ring
> }}}
>
> This ticket serves as a catch-all for such unexpected types.

New description:

 It is generally preferred that the returned result type matches the
 argument type when calling a builtin function. For example this is as
 expected:
 {{{
 sage: factorial(8).parent()
 Integer Ring
 sage: factorial(SR(8)).parent()
 Symbolic Ring
 sage: exp(0).parent()
 Integer Ring
 sage: exp(SR(0)).parent()
 Symbolic Ring
 }}}
 but this is not:
 {{{
 from sage.symbolic.function import BuiltinFunction

 class TestFunction(BuiltinFunction):
     def __init__(self):
         BuiltinFunction.__init__(self, "testfun", nargs=2)
     def _eval_(self, n, x, *args, **kwds):
         print (parent(n), parent(x))
         return SR(5)

 sage: TestFunction()(SR(1),GF(2)(1))
 (Integer Ring, Finite Field of size 2)
 5
 sage: type(_)
 <type 'int'>
 }}}
 An explanation could be that `factorial` and `exp` derive from
 `GinacFunction`.

--

--
Ticket URL: <http://trac.sagemath.org/ticket/17953#comment:1>
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