Opened 9 years ago
Closed 7 years ago
#12295 closed defect (fixed)
maple interface broken
Reported by:  sluther  Owned by:  was 

Priority:  major  Milestone:  sage6.4 
Component:  interfaces  Keywords:  maple interface 
Cc:  Merged in:  
Authors:  J Miguel Farto  Reviewers:  Frédéric Chapoton, Volker Braun 
Report Upstream:  N/A  Work issues:  
Branch:  a8321cc (Commits, GitHub, GitLab)  Commit:  a8321ccd24b7d87df44d7668484e99eb8f767544 
Dependencies:  Stopgaps: 
Description (last modified by )
With sage4.7 (and maple 14) it works:
  Sage Version 4.7, Release Date: 20110523   Type notebook() for the GUI, and license() for information.   sage: maple('1+1') 2 sage:
But with 4.7.2 all maple commands end in this traceback:
  Sage Version 4.7.2, Release Date: 20111029   Type notebook() for the GUI, and license() for information.   sage: maple('1+1') ERROR: An unexpected error occurred while tokenizing input The following traceback may be corrupted or invalid The error message is: ('EOF in multiline statement', (17, 0))  RuntimeError Traceback (most recent call last) /home/luther/<ipython console> in <module>() /home/luther/sage4.7.2linux64bitubuntu_10.04.3_ltsx86_64Linux/local/lib/python2.6/sitepackages/IPython/Prompts.pyc in __call__(self, arg) 550 551 # and now call a possibly userdefined print mechanism > 552 manipulated_val = self.display(arg) 553 554 # user display hooks can change the variable to be stored in /home/luther/sage4.7.2linux64bitubuntu_10.04.3_ltsx86_64Linux/local/lib/python2.6/sitepackages/IPython/Prompts.pyc in _display(self, arg) 576 return IPython.generics.result_display(arg) 577 except TryNext: > 578 return self.shell.hooks.result_display(arg) 579 580 # Assign the default display method: /home/luther/sage4.7.2linux64bitubuntu_10.04.3_ltsx86_64Linux/local/lib/python2.6/sitepackages/IPython/hooks.pyc in __call__(self, *args, **kw) 139 #print "prio",prio,"cmd",cmd #dbg 140 try: > 141 ret = cmd(*args, **kw) 142 return ret 143 except ipapi.TryNext, exc: /home/luther/sage4.7.2linux64bitubuntu_10.04.3_ltsx86_64Linux/local/lib/python2.6/sitepackages/sage/misc/displayhook.pyc in result_display(ip_self, obj) 148 # IPython's default result_display() uses the IPython.genutils.Term.cout stream. 149 # See also local/lib/python2.6/sitepackages/IPython/hooks.py. > 150 print_obj(IPython.genutils.Term.cout, obj) 151 152 def displayhook(obj): /home/luther/sage4.7.2linux64bitubuntu_10.04.3_ltsx86_64Linux/local/lib/python2.6/sitepackages/sage/misc/displayhook.pyc in print_obj(out_stream, obj) 140 if _check_tall_list_and_print(out_stream, obj): 141 return > 142 print >>out_stream, `obj` 143 144 def result_display(ip_self, obj): /home/luther/sage4.7.2linux64bitubuntu_10.04.3_ltsx86_64Linux/local/lib/python2.6/sitepackages/sage/interfaces/maple.pyc in __repr__(self) 1056 """ 1057 self._check_valid() > 1058 return self.parent().get(self._name) 1059 1060 def _latex_(self): /home/luther/sage4.7.2linux64bitubuntu_10.04.3_ltsx86_64Linux/local/lib/python2.6/sitepackages/sage/interfaces/maple.pyc in get(self, var) 609 '2' 610 """ > 611 s = self.eval('printf("%%q",%s)'%var) 612 return s 613 /home/luther/sage4.7.2linux64bitubuntu_10.04.3_ltsx86_64Linux/local/lib/python2.6/sitepackages/sage/interfaces/expect.pyc in eval(self, code, strip, synchronize, locals, allow_use_file, split_lines, **kwds) 1034 if (split_lines is "nofile" and allow_use_file and 1035 self._eval_using_file_cutoff and len(code) > self._eval_using_file_cutoff): > 1036 return self._eval_line_using_file(code) 1037 elif split_lines: 1038 return '\n'.join([self._eval_line(L, allow_use_file=allow_use_file, **kwds) /home/luther/sage4.7.2linux64bitubuntu_10.04.3_ltsx86_64Linux/local/lib/python2.6/sitepackages/sage/interfaces/expect.pyc in _eval_line_using_file(self, line) 653 tmp_to_use = self._remote_tmpfile() 654 try: > 655 s = self._eval_line(self._read_in_file_command(tmp_to_use), allow_use_file=False) 656 except pexpect.EOF, msg: 657 if self._quit_string() in line: /home/luther/sage4.7.2linux64bitubuntu_10.04.3_ltsx86_64Linux/local/lib/python2.6/sitepackages/sage/interfaces/maple.pyc in _eval_line(self, line, allow_use_file, wait_for_prompt) 559 e.expect('__sage__;') 560 e.expect(self._prompt) > 561 raise RuntimeError, "An error occurred running a Maple command:\nINPUT:\n%s\nOUTPUT:\n%s"%(line, z) 562 return z 563 RuntimeError: An error occurred running a Maple command: INPUT: read "/home/luther/.sage//temp/dirac/18306//interface//tmp18309"; OUTPUT: on line 2, unexpected end of input Error, while reading `/home/luther/.sage//temp/dirac/18306//interface//tmp18309`
Attachments (3)
Change History (33)
comment:1 Changed 8 years ago by
 Patch to apply: trac12295maple_interface_20130115.patch
 Versions:
 Sage 5.6
 Maple 13
 Linux Mint 14 cinnamon edition x86_64
 Dependencies: None
 Causes:
 Maple command line interface automatically breaks input lines so pexpect interface sometimes fails (e.g. when the Sage user's home has a long route).
 When this is fixed, a new bug appears because the method sage.interfaces.maple.Maple._eval_line_using_file did not manage the Maple's ";"stuff.
 When these bugs are corrected, a new issue appears in sage.interfaces.maple.Maple._keyboard_interrupt. If we expect two maple prompts, the interface freezes when hitting ctrlc once to stop a long calculation.
 Fixes:
The Maple command passed to sage.interfaces.expect.Expect contains now a Maple configuration command.
 Now, Maple command line interface does not break input lines.
 When an Maple syntax error occurs, the command line interface does not enter in edit mode. Thus, we are not restricted to only use the expect file interface.
 Additional changes:
 The method sage.interfaces.maple.Maple.clear was modified to provide a standard way to eventually clear a Maple variable.
 Some docstrings are changed to pass the doctests.
 A docstring is changed in sage.symbolic.integration.integral to pass the tests of Ticket #2120
 Related tickets: The issues of Tickets #2120 and #1465 could be also fixed with this patch, but not sure.
 Tests passed:
comment:2 Changed 8 years ago by
 trac12295maple_interface_20130115.patch works with Sage 5.6 and 5.7
 trac12295maple_interface_20130321.patch is a similar patch but for Sage 5.8
 trac12295maple_interface_5.9_20130614.patch is a similar patch but for Sage 5.9
comment:3 Changed 8 years ago by
 Status changed from new to needs_info
Please put your real name on both the patch and the ticket "Author" description.
comment:4 Changed 8 years ago by
comment:5 Changed 8 years ago by
 Milestone changed from sage5.11 to sage5.12
comment:6 Changed 7 years ago by
 Milestone changed from sage6.1 to sage6.2
comment:7 Changed 7 years ago by
 Description modified (diff)
comment:8 Changed 7 years ago by
 Description modified (diff)
comment:9 Changed 7 years ago by
 Status changed from needs_info to needs_review
comment:10 Changed 7 years ago by
 Milestone changed from sage6.2 to sage6.3
comment:11 Changed 7 years ago by
 Branch set to u/chapoton/12295
 Commit set to 67871caedf019bbefec1c8127e65a226169c8a4d
 Keywords maple interface added
Here is a git branch. Could somebody please have a look before it rosts ?
New commits:
67871ca  maple interface fix for sage 5.8

comment:12 Changed 7 years ago by
 Milestone changed from sage6.3 to sage6.4
comment:13 Changed 7 years ago by
Branch u/chapoton/12295 merged with 6.3 sources. Tested for Linux mint 17 and maple 13. It works fine.
comment:14 Changed 7 years ago by
Would you give a positive review, then ?
comment:15 Changed 7 years ago by
I have been successfully using the fix for more than a year.
comment:16 Changed 7 years ago by
Then could you please put this ticket in positive review, so that it can be closed ?
comment:17 Changed 7 years ago by
 Status changed from needs_review to positive_review
comment:18 Changed 7 years ago by
 Status changed from positive_review to needs_info
@chapoton: Umm... Miguel IS the author! So he definitely can't review it. However, if it solves the problem for you as well (perhaps on a different platform? having someone test on Mac would be good) that would be great for positive review. I'll put a note on sagedevel.
comment:19 Changed 7 years ago by
Why are those marked random? This should have deterministic output (depending on maple of course):
 sage: g = maple(f); g # optional  maple + sage: g = maple(f); g # random ; optional  maple sin(x^2)+y^z  sage: g.integrate(x) # optional  maple + sage: g.integrate(x) # random ; optional  maple 1/2*2^(1/2)*Pi^(1/2)*FresnelS(2^(1/2)/Pi^(1/2)*x)+y^z*x
comment:20 followup: ↓ 21 Changed 7 years ago by
The order of the operands is sessiondependent in maple. Sometimes the tests didn't passed due to this fact, when I performed them (long time ago). I know that this "random" setting makes the tests (mathematically) useless, but I don't know how to address this problem. Maybe now the test suite takes into account this issue.
comment:21 in reply to: ↑ 20 Changed 7 years ago by
Replying to migeruhito:
The order of the operands is sessiondependent in maple.
I believe starting maple with option setsort=1
and then calling (maple's) sort()
on the result before sending it back to sage should make the output deterministic, at least on these examples.
comment:22 followup: ↓ 24 Changed 7 years ago by
I performed my tests with maple 11. Prior to Maple 12, the only sort option available is session dependent, and I think setsort
option is not available at all. By including it, we will probably break the interface for older versions of maple. In the other hand, setsort=1
seems to be deterministic for these examples as mmezzarobba said, but it is the default from version 12. sort()
is not necessary in this case.
I think that "random" must be removed from the tests and setsort=1
must not be added in the call parameters of the maple interface. Then, the status of the question would be:
 For Maple prior to v. 11, the tests will randomly pass.
 For Maple from v. 12, the tests will probably pass. (From Maple documentation:: "The setsort=orderNumber option changes the sort order for Maple sets". I believe that maple expressions are ordered like sets, but not sure).
comment:23 Changed 7 years ago by
Sounds good to me.
comment:24 in reply to: ↑ 22 Changed 7 years ago by
Replying to migeruhito:
I performed my tests with maple 11. Prior to Maple 12, the only sort option available is session dependent, and I think
setsort
option is not available at all. By including it, we will probably break the interface for older versions of maple. In the other hand,setsort=1
seems to be deterministic for these examples as mmezzarobba said, but it is the default from version 12.sort()
is not necessary in this case.
Yes, I forgot that setsort=1
was in fact the default. However, while sets are sorted by default under recent versions of Maple, it looks like expressions aren't. For example, with Maple 17, I get:
$ maple t #>sin(x^2)+y^z; sin(x^2)+y^z #>{sin(x^2),y^z}; {y^z, sin(x^2)} #>sort(%%); y^z+sin(x^2)
So I would say that adding the commandline option is indeed not necessary, but we do need to call sort()
to make the tests deterministic under Maple 12+.
I believe that maple expressions are ordered like sets, but not sure).
Same for me.
comment:25 Changed 7 years ago by
 Commit changed from 67871caedf019bbefec1c8127e65a226169c8a4d to d256c5c337eb6853fb2c1ec574d9b56c8ec6802d
comment:26 Changed 7 years ago by
 Commit changed from d256c5c337eb6853fb2c1ec574d9b56c8ec6802d to a8321ccd24b7d87df44d7668484e99eb8f767544
Branch pushed to git repo; I updated commit sha1. New commits:
a8321cc  trac #12295 remove bad internet optional tag

comment:27 Changed 7 years ago by
 Status changed from needs_info to needs_review
Is this ok like that ?
I regret that testing optional=something
does not run the "notoptional" tests. This prevents from the optional=maple
tests to pass for me in this ticket in the current state.
But the optional=all
do pass (except for the mathematica optional ones, cause I do not have that.
comment:28 Changed 7 years ago by
You can run standard + optional maple tests with
sage t optional=sage,maple src/sage/foo.py
comment:29 Changed 7 years ago by
 Reviewers set to Frédéric Chapoton, Volker Braun
 Status changed from needs_review to positive_review
comment:30 Changed 7 years ago by
 Branch changed from u/chapoton/12295 to a8321ccd24b7d87df44d7668484e99eb8f767544
 Resolution set to fixed
 Status changed from positive_review to closed