#9705: trouble with long lines in notebook magma mode
------------------------+---------------------------------------------------
Reporter: nbruin | Owner: jason, was
Type: defect | Status: new
Priority: major | Milestone: sage-4.6.2
Component: notebook | Keywords:
Author: | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
------------------------+---------------------------------------------------
Comment(by kedlaya):
Here's a similar but even stranger example. This valid Magma which should
return nothing, but it returns an error when evaluated in a notebook cell:
{{{
MR:=MatrixRing(Rationals(),4);
embed:=function(A);
return
MR!Matrix([[A[1][1],A[1][2],0,0],[A[2][1],A[2][2],0,0],[0,0,A[1][1],A[1][2]],[0,0,0,A[2][2]]]);
end function;
///
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_27.py", line 10, in <module>
exec compile(u"print _support_.syseval(magma,
u'MR:=MatrixRing(Rationals(),4); \\nembed:=function(A); \\nreturn
MR!Matrix([[A[1][1],A[1][2],0,0],[A[2][1],A[2][2],0,0],[0,0,A[1][1],A[1][2]],[0,0,0,A[2][2]]]);
\\nend function;', __SAGE_TMP_DIR__)" + '\n', '', 'single')
File "", line 1, in <module>
File "/scratch/sage-x64/devel/sagenb-main/sagenb/misc/support.py", line
473, in syseval
return system.eval(cmd, sage_globals, locals = sage_globals)
File "/scratch/sage-x64/local/lib/python2.6/site-
packages/sage/interfaces/magma.py", line 523, in eval
raise RuntimeError, "Error evaluating Magma code.\nIN:%s\nOUT:%s"%(x,
ans)
RuntimeError: Error evaluating Magma code.
IN:MR:=MatrixRing(Rationals(),4);
embed:=function(A);
return
MR!Matrix([[A[1][1],A[1][2],0,0],[A[2][1],A[2][2],0,0],[0,0,A[1][1],A[1][2]],[0,0,0,A[2][2]]]);
end function;
OUT:
>> load
"/home/r1/kedlaya/.sage//temp/dwork.mit.edu/32584//interface//tmp32588
^
User error: bad syntax
>> end function;
^
User error: bad syntax
}}}
Apparently the last line got separated from the rest by mistake. The same
sort of thing happens if I concatenate the first two commands into one
line and the other two into a second line. But if I make the line even
longer by concatenating all four commands together, the error vanishes!
{{{
MR:=MatrixRing(Rationals(),4); embed:=function(A); return
MR!Matrix([[A[1][1],A[1][2],0,0],[A[2][1],A[2][2],0,0],[0,0,A[1][1],A[1][2]],[0,0,0,A[2][2]]]);
end function;
///
}}}
I can also avoid the error by slightly shortening the third line in the
original (e.g., by changing the last nonzero matrix entry to 0).
I suppose what's going on is that Sage never breaks up an individual line,
but it does or does not concatenate multiple lines into the same temporary
file based on length considerations. This clearly needs to be done more
intelligently.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9705#comment:2>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.