Opened 8 years ago
Closed 8 years ago
#1491 closed defect (fixed)
[with patch, with positive review] improve conversion from interface to sage objects (i.e., the dot sage method)
Reported by: | was | Owned by: | was |
---|---|---|---|
Priority: | major | Milestone: | sage-2.9 |
Component: | interfaces | Keywords: | |
Cc: | Merged in: | ||
Authors: | Reviewers: | ||
Report Upstream: | Work issues: | ||
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
On Dec 13, 2007 11:54 AM, Timothy Clemans <timothy.clemans@gmail.com> wrote: > > I'm getting > > {{{id=2| > def math_bessel_K(nu,x): > return mathematica(nu).BesselK(x).N(20).sage() > math_bessel_K(2,I) > /// > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "/home/tclemans/.sage/sage_notebook/worksheets/admin/5/code/ > 9.py", line 6, in <module> > exec compile(ur'math_bessel_K(Integer(2),I)' + '\n', '', 'single') > File "/home/was/s/data/extcode/sage/", line 1, in <module> > > File "/home/tclemans/.sage/sage_notebook/worksheets/admin/5/code/ > 9.py", line 5, in math_bessel_K > return mathematica(nu).BesselK(x).N(Integer(20)).sage() > File "/home/was/s/local/lib/python2.5/site-packages/sage/interfaces/ > expect.py", line 1086, in sage > return self._sage_() > File "/home/was/s/local/lib/python2.5/site-packages/sage/interfaces/ > expect.py", line 1079, in _sage_ > return sage.misc.sage_eval.sage_eval(repr(self)) > File "/home/was/s/local/lib/python2.5/site-packages/sage/misc/ > sage_eval.py", line 112, in sage_eval > raise SyntaxError, "%s\nError using SAGE to evaluate '%s'"%(msg, > p) > SyntaxError: invalid syntax (<string>, line 1) > Error using SAGE to evaluate '- > RealNumber('2.592886175491196978167651322538251462935637034451900356688') > + > > RealNumber('0.180489972066962026629620880838378650496225604668529521981')*I' > }}} That's coming from a newline, which appears in Mathematica 5 I guess, but not 6. Anyway, the patch I justed posted at fixes the problem. Alternatively rewrite the function like this: sage: def math_bessel_K(nu,x): return sage_eval(repr(mathematica(nu).BesselK(x).N(20)).replace('\n','')) Important note: The conversion from Mathematica to Sage, i.e., mathematica_object.sage() is very naive still -- all it is is basically sage_eval(repr(...))! This could/would be improved if somebody cared a lot. William
Attachments (1)
Change History (3)
Changed 8 years ago by was
comment:1 Changed 8 years ago by cwitty
- Summary changed from [with patch] improve conversion from interface to sage objects (i.e., the dot sage method) to [with patch, with positive review] improve conversion from interface to sage objects (i.e., the dot sage method)
comment:2 Changed 8 years ago by mabshoff
- Resolution set to fixed
- Status changed from new to closed
Merged in 2.9.rc0.
Note: See
TracTickets for help on using
tickets.
Looks good. (Looks reasonable, and sage/interfaces/mathematica.py doctests pass on sage.math.)