Opened 5 years ago

Closed 19 months ago

#16801 closed defect (fixed)

Conversion of psi(x,y) to/from SymPy

Reported by: rws Owned by:
Priority: major Milestone: sage-8.1
Component: interfaces Keywords: _sage_, integrate, sympy
Cc: Merged in:
Authors: Ralf Stephan Reviewers: Marcelo Forets
Report Upstream: N/A Work issues:
Branch: 9c4119a (Commits) Commit: 9c4119a3feda956846bd1fa78256830aef4739f8
Dependencies: #20204 Stopgaps:

Description (last modified by rws)

integrate(psi(x), x, algorithm='sympy')
...
/home/ralf/sage/local/lib/python2.7/site-packages/sympy-1.0-py2.7.egg/sympy/core/function.pyc in _sage_(self)
    705         import sage.all as sage
    706         fname = self.func.__name__
--> 707         func = getattr(sage, fname)
    708         args = [arg._sage_() for arg in self.args]
    709         return func(*args)

AttributeError: 'module' object has no attribute 'polygamma'

Previous description:

sage: integrate(1/(x^3 *(a+b*x)^(1/3)), x, algorithm='sympy')
...
AttributeError: 'gamma' object has no attribute '_sage_'

Change History (14)

comment:1 Changed 5 years ago by rws

  • Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_review

Duplicate of #15057 which however misses gamma.

comment:2 Changed 5 years ago by rws

  • Milestone changed from sage-duplicate/invalid/wontfix to sage-6.4
  • Status changed from needs_review to needs_work

Not quite. It appears to be the other direction that's missing.

comment:3 Changed 5 years ago by rws

I think this naturally needs a general solution that uses the conversions dictionary given with every special function in Sage.

comment:4 Changed 3 years ago by rws

  • Description modified (diff)
  • Keywords sympy added; mpmath removed
  • Milestone changed from sage-6.4 to sage-7.4
  • Report Upstream changed from N/A to Not yet reported upstream; Will do shortly.
  • Summary changed from not all sympy function results get translated to Sage to Not all sympy function results get translated to Sage

gamma is now converted from Sympy, the original case however takes very long to doctest. Is there a faster case that returns something with gamma in Sympy?

Also, additionally now, polygamma does not convert, as in integrate(psi(x), x, algorithm='sympy').

comment:5 Changed 19 months ago by rws

  • Branch set to u/rws/16801

comment:6 Changed 19 months ago by rws

  • Authors set to Ralf Stephan
  • Commit set to 9c4119a3feda956846bd1fa78256830aef4739f8
  • Dependencies set to #20204
  • Milestone changed from sage-7.4 to sage-8.1
  • Report Upstream changed from Not yet reported upstream; Will do shortly. to N/A
  • Status changed from needs_work to needs_review
  • Summary changed from Not all sympy function results get translated to Sage to Conversion of psi(x,y) to/from SymPy

Last 10 new commits:

a68d57f23923: Interface cases function with SymPy's piecewise
b80d98c23923: fix typo
2afa0ee22566: interface SymPy's ceiling()
9494f6c22566: add test
8215d37Merge branch 'develop' into tmp05
7899ea920204: convert SymPy abstract functions
b261ec323923: fix doctest
5010acfMerge branch 'u/rws/23923' of git://trac.sagemath.org/sage into t/20204/20204
14b1c5220204: more doctests
9c4119a16801: Conversion of psi(x,y) to/from SymPy

comment:7 Changed 19 months ago by jdemeyer

  • Status changed from needs_review to needs_work

Could you add at least one direct doctest of the function _sympysage_polygamma?

comment:8 Changed 19 months ago by rws

  • Status changed from needs_work to needs_review

Since there is no pressing need for it, please open another ticket.

comment:9 Changed 19 months ago by mforets

  • Status changed from needs_review to positive_review

LGTM.

all the following more direct tests work. i can add one, but don't know where exactly.

sage: f = 25/12 + psi(5, hold=true); f
psi(5) + 25/12
sage: f._sympy_()
-EulerGamma + 25/6
sage: f.unhold()
-euler_gamma + 25/6
sage: from sympy import Symbol, polygamma as pg
sage: bool(pg(1, x)._sage_().subs(x=1) + 1/6*pi^2 == 0)
True

comment:10 Changed 19 months ago by mforets

  • Reviewers set to Marcelo Forets

comment:11 Changed 19 months ago by mforets

perhaps in the module's docstring of interfaces/sympy.py, to add those and maybe other examples, so that they also show up in the htmldoc.

comment:12 follow-up: Changed 19 months ago by rws

Thanks. Please go ahead.

comment:13 in reply to: ↑ 12 Changed 19 months ago by mforets

Replying to rws:

Thanks. Please go ahead.

ok, this is now #24112.

comment:14 Changed 19 months ago by vbraun

  • Branch changed from u/rws/16801 to 9c4119a3feda956846bd1fa78256830aef4739f8
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.