Opened 14 years ago

Closed 14 years ago

#3752 closed defect (fixed)

[with patch, positive review] gap.eval -- oddity in parsing multiline input and comments

Reported by: was Owned by: mhansen
Priority: major Milestone: sage-3.3
Component: interfaces Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

On Thu, Jul 31, 2008 at 11:20 AM, Peter <> wrote:
>
> Hi,
>
> I'm trying to use some GAP code in the Sage notebook, and the code has
> many one-line comments in it (starting with #). I switched the
> notebook to gap mode (using the dropdown menu) and then noticed that
> in each cell only commands that appear before the first comment are
> processed by GAP. The same happens in cells that start with %gap.
>
> Can someone perhaps verify this behaviour and/or suggest a fix? (I'm
> using Sage 3.0.5, and the same behaviour seems to occur on
> Sagenb.org.)

Yes, here's an example of this in the sage notebook text form (I made the triple {'s into double for this ticket): 

{{{
Untitled
system:gap


{{id=112|
Print(2 + 2); # add numbers
Print(3 + 3); # add more numbers
///

4
}}
}}}

Attachments (1)

trac_3752.patch (4.0 KB) - added by mhansen 14 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 14 years ago by jipsen

This problem can be fixed by adding the following lines at the start of the eval method in the file interfaces/gap.py:

        # remove comments, replace newlines by space
        x = "".join([(r[:r.find('#')] if r.find('#')!=-1 else r)+' ' \
                     for r in x.split('\n')])

(This still needs to be tested on a variety of GAP input lines.)

I also noticed that if the length of the string processed by GAP is more than ~103 characters, then no output is produced (although the GAP code seems to be evaluated correctly and any functions defined in the code works in subsequent notebook cells).

Here is an example:

{{id=112|
%gap
test := function()
return "make a long input string  (delete 1 char to see the output)";
end;
test();
///
}}

Changed 14 years ago by mhansen

comment:2 Changed 14 years ago by mhansen

  • Owner changed from was to mhansen
  • Status changed from new to assigned
  • Summary changed from gap.eval -- oddity in parsing multiline input and comments to [with patch, needs review] gap.eval -- oddity in parsing multiline input and comments

comment:3 Changed 14 years ago by malb

  • Summary changed from [with patch, needs review] gap.eval -- oddity in parsing multiline input and comments to [with patch, positive review] gap.eval -- oddity in parsing multiline input and comments

I have a performance concern, but this is #5086 now.

comment:4 Changed 14 years ago by mabshoff

  • Milestone changed from sage-3.4.1 to sage-3.3
  • Resolution set to fixed
  • Status changed from assigned to closed

Merged in Sage 3.3.alpha2

Cheers,

Michael

Note: See TracTickets for help on using tickets.