Opened 7 years ago

Closed 4 years ago

#12295 closed defect (fixed)

maple interface broken

Reported by: sluther Owned by: was
Priority: major Milestone: sage-6.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) Commit: a8321ccd24b7d87df44d7668484e99eb8f767544
Dependencies: Stopgaps:

Description (last modified by mmezzarobba)

With sage-4.7 (and maple 14) it works:

----------------------------------------------------------------------
| Sage Version 4.7, Release Date: 2011-05-23                         |
| 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: 2011-10-29                       |
| 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 multi-line statement', (17, 0))

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)

/home/luther/<ipython console> in <module>()

/home/luther/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/IPython/Prompts.pyc in __call__(self, arg)
    550 
    551             # and now call a possibly user-defined print mechanism
--> 552             manipulated_val = self.display(arg)
    553             
    554             # user display hooks can change the variable to be stored in

/home/luther/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/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/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/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/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/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/site-packages/IPython/hooks.py.
--> 150     print_obj(IPython.genutils.Term.cout, obj)
    151 
    152 def displayhook(obj):

/home/luther/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/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/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/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/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/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/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/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/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/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/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/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`

see also #2120, #11288

Attachments (3)

trac-12295-maple_interface_20130115.patch (10.3 KB) - added by migeruhito 6 years ago.
Fix Maple interface
trac-12295-maple_interface_20130321.patch (10.3 KB) - added by migeruhito 6 years ago.
Maple interface fix for Sage 5.8
trac-12295-maple_interface_5.9_20130614.patch (9.9 KB) - added by migeruhito 6 years ago.
Maple interface fix for Sage 5.9

Download all attachments as: .zip

Change History (33)

comment:1 Changed 6 years ago by migeruhito

  • Patch to apply: trac-12295-maple_interface_20130115.patch
  • Versions:
    • Sage 5.6
    • Maple 13
    • Linux Mint 14 cinnamon edition x86_64
  • Dependencies: None
  • Causes:
    1. 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).
    2. 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.
    3. 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 ctrl-c once to stop a long calculation.
  • Fixes: The Maple command passed to sage.interfaces.expect.Expect contains now a Maple configuration command.
    1. Now, Maple command line interface does not break input lines.
    2. 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:
    1. The method sage.interfaces.maple.Maple.clear was modified to provide a standard way to eventually clear a Maple variable.
    2. Some docstrings are changed to pass the doctests.
    3. 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:
    sage -coverage devel/sage-maple/sage/interfaces/maple.py
    sage -t -optional devel/sage-maple/sage/interfaces/maple.py
    sage -t --only-optional=maple devel/sage-maple/sage/interfaces/maple.py
    sage -t --only-optional=maple devel/sage/sage/symbolic/expression.pyx  
    sage -t --only-optional=maple devel/sage/sage/symbolic/integration/integral.py
    sage -t --only-optional=maple devel/sage/sage/calculus/calculus.py
    sage -t --only-optional=maple devel/sage/sage/misc/functional.py
    sage -t --only-optional=maple devel/sage/sage/tests/benchmark.py
    sage -t --only-optional=maple devel/sage/sage/interfaces/maple.py
    sage --testall --long
    sage -docbuild reference html
    sage -docbuild reference pdf
    
Last edited 6 years ago by migeruhito (previous) (diff)

Changed 6 years ago by migeruhito

Fix Maple interface

comment:2 Changed 6 years ago by migeruhito

  • trac-12295-maple_interface_20130115.patch works with Sage 5.6 and 5.7
  • trac-12295-maple_interface_20130321.patch is a similar patch but for Sage 5.8
  • trac-12295-maple_interface_5.9_20130614.patch is a similar patch but for Sage 5.9
Last edited 6 years ago by migeruhito (previous) (diff)

comment:3 Changed 6 years ago by kcrisman

  • Status changed from new to needs_info

Please put your real name on both the patch and the ticket "Author" description.

Changed 6 years ago by migeruhito

Maple interface fix for Sage 5.8

comment:4 Changed 6 years ago by migeruhito

  • Authors set to J Miguel Farto

Changed 6 years ago by migeruhito

Maple interface fix for Sage 5.9

comment:5 Changed 6 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:6 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:7 Changed 5 years ago by mmezzarobba

  • Description modified (diff)

comment:8 Changed 5 years ago by mmezzarobba

  • Description modified (diff)

comment:9 Changed 5 years ago by rws

  • Status changed from needs_info to needs_review

comment:10 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:11 Changed 5 years ago by chapoton

  • 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:

67871camaple interface fix for sage 5.8

comment:12 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:13 Changed 4 years ago by migeruhito

Branch u/chapoton/12295 merged with 6.3 sources. Tested for Linux mint 17 and maple 13. It works fine.

comment:14 Changed 4 years ago by chapoton

Would you give a positive review, then ?

comment:15 Changed 4 years ago by migeruhito

I have been successfully using the fix for more than a year.

comment:16 Changed 4 years ago by chapoton

Then could you please put this ticket in positive review, so that it can be closed ?

comment:17 Changed 4 years ago by migeruhito

  • Status changed from needs_review to positive_review

comment:18 Changed 4 years ago by kcrisman

  • 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 sage-devel.

comment:19 Changed 4 years ago by vbraun

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 follow-up: Changed 4 years ago by migeruhito

The order of the operands is session-dependent 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 4 years ago by mmezzarobba

Replying to migeruhito:

The order of the operands is session-dependent 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 follow-up: Changed 4 years ago by 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.

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).
Last edited 4 years ago by migeruhito (previous) (diff)

comment:23 Changed 4 years ago by vbraun

Sounds good to me.

comment:24 in reply to: ↑ 22 Changed 4 years ago by mmezzarobba

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 command-line 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 4 years ago by git

  • Commit changed from 67871caedf019bbefec1c8127e65a226169c8a4d to d256c5c337eb6853fb2c1ec574d9b56c8ec6802d

Branch pushed to git repo; I updated commit sha1. New commits:

864f111Merge with 6.4.beta3
d256c5ctrac #12295 using .sort() to make the tests deterministic

comment:26 Changed 4 years ago by git

  • Commit changed from d256c5c337eb6853fb2c1ec574d9b56c8ec6802d to a8321ccd24b7d87df44d7668484e99eb8f767544

Branch pushed to git repo; I updated commit sha1. New commits:

a8321cctrac #12295 remove bad internet optional tag

comment:27 Changed 4 years ago by chapoton

  • Status changed from needs_info to needs_review

Is this ok like that ?

I regret that testing optional=something does not run the "not-optional" 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 4 years ago by vbraun

You can run standard + optional maple tests with

sage -t --optional=sage,maple src/sage/foo.py

comment:29 Changed 4 years ago by vbraun

  • Reviewers set to Frédéric Chapoton, Volker Braun
  • Status changed from needs_review to positive_review

comment:30 Changed 4 years ago by vbraun

  • Branch changed from u/chapoton/12295 to a8321ccd24b7d87df44d7668484e99eb8f767544
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.