#14446: missing Sage interface for SymPy's RisingFactorial
------------------------------+------------------------
       Reporter:  zimmerma    |        Owner:  was
           Type:  defect      |       Status:  new
       Priority:  minor       |    Milestone:  sage-6.4
      Component:  interfaces  |   Resolution:
       Keywords:              |    Merged in:
        Authors:              |    Reviewers:
Report Upstream:  N/A         |  Work issues:
         Branch:              |       Commit:
   Dependencies:              |     Stopgaps:
------------------------------+------------------------

Old description:

> This is related to #14437:
> {{{
> sage: from sympy import Function, Symbol
> sage: u = Function('u')
> sage: n = Symbol('n', integer=True)
> sage: from sympy import rsolve
> sage: f = u(n+2) - u(n+1) + u(n)/4
> sage: rsolve(f,u(n))
> 2**(-n)*C0*RisingFactorial(C0/C1 + 1, n)/RisingFactorial(C0/C1, n)
> }}}
> The result returned by {{{rsolve}}} is a SymPy object:
> {{{
> sage: s = rsolve(f,u(n))
> sage: type(s)
> <class 'sympy.core.mul.Mul'>
> }}}
> Ideally, it should be automatically converted to Sage.
>
> However, if we try to convert it manually, we get:
> {{{
> sage: s._sage_()
> ---------------------------------------------------------------------------
> AttributeError                            Traceback (most recent call
> last)
>
> /users/caramel/zimmerma/svn/sagebook/tex/<ipython console> in <module>()
>
> /usr/local/sage-5.1-linux-64bit-ubuntu_12.04_lts-
> x86_64-Linux/local/lib/python2.7/site-packages/sympy/core/mul.py in
> _sage_(self)
>    1192         s = 1
>    1193         for x in self.args:
> -> 1194             s *= x._sage_()
>    1195         return s
>    1196
>
> /usr/local/sage-5.1-linux-64bit-ubuntu_12.04_lts-
> x86_64-Linux/local/lib/python2.7/site-packages/sympy/core/power.py in
> _sage_(self)
>     846
>     847     def _sage_(self):
> --> 848         return self.args[0]._sage_()**self.args[1]._sage_()
>     849
>     850 from add import Add
>
> AttributeError: 'RisingFactorial' object has no attribute '_sage_'
> }}}
> Paul

New description:

 Minimal test case:
 {{{
 sage: import sympy
 sage: SR(sympy.RisingFactorial(x,x))
 AttributeError: 'RisingFactorial' object has no attribute '_sage_'
 sage: SR(sympy.FallingFactorial(x,x))
 AttributeError: 'FallingFactorial' object has no attribute '_sage_'
 }}}
 Original ticket description:

 This is related to #14437:
 {{{
 sage: from sympy import Function, Symbol
 sage: u = Function('u')
 sage: n = Symbol('n', integer=True)
 sage: from sympy import rsolve
 sage: f = u(n+2) - u(n+1) + u(n)/4
 sage: rsolve(f,u(n))
 2**(-n)*C0*RisingFactorial(C0/C1 + 1, n)/RisingFactorial(C0/C1, n)
 }}}
 The result returned by {{{rsolve}}} is a SymPy object:
 {{{
 sage: s = rsolve(f,u(n))
 sage: type(s)
 <class 'sympy.core.mul.Mul'>
 }}}
 Ideally, it should be automatically converted to Sage.

 However, if we try to convert it manually, we get:
 {{{
 sage: s._sage_()
 ---------------------------------------------------------------------------
 AttributeError                            Traceback (most recent call
 last)

 /users/caramel/zimmerma/svn/sagebook/tex/<ipython console> in <module>()

 /usr/local/sage-5.1-linux-64bit-ubuntu_12.04_lts-
 x86_64-Linux/local/lib/python2.7/site-packages/sympy/core/mul.py in
 _sage_(self)
    1192         s = 1
    1193         for x in self.args:
 -> 1194             s *= x._sage_()
    1195         return s
    1196

 /usr/local/sage-5.1-linux-64bit-ubuntu_12.04_lts-
 x86_64-Linux/local/lib/python2.7/site-packages/sympy/core/power.py in
 _sage_(self)
     846
     847     def _sage_(self):
 --> 848         return self.args[0]._sage_()**self.args[1]._sage_()
     849
     850 from add import Add

 AttributeError: 'RisingFactorial' object has no attribute '_sage_'
 }}}
 Paul

--

Comment (by rws):

 This is now fixed in the proposed sympy pull request
 https://github.com/sympy/sympy/pull/8592
 but we will upload a branch with the specific sympy patch next.

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