Ticket #1166 (closed defect: fixed)

Opened 6 years ago

Last modified 5 years ago

[with patch; with positive review] 2D terminal output is inconsistent and corrupted

Reported by: zimmerma Owned by: was
Priority: major Milestone: sage-2.10.1
Component: user interface Keywords:
Cc: Work issues:
Report Upstream: Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description

sage: f = (exp(x)-1)/(exp(x/2)+1)
sage: g = exp(x/2)-1
sage: print f(10.0), g(10.0)
                               147.4131591025766                               \
 147.4131591025766
sage: print 1, 2
1 2
sage: print f(10), g(10)
                                     10
                                    e   - 1
                                   --------
                                     5
                                    e  + 1                                     \
  5
                                     e  - 1

The output of f(10.0), g(10.0) [with many spaces] seems inconsistent with that of 1, 2 [no spaces]. With f(10), g(10) the exponent 5 of g(10) wraps around the terminal line, and is thus not properly aligned with e - 1. (all this in a 80-column xterm)

Attachments

trac-1166.patch Download (1.3 KB) - added by was 5 years ago.

Change History

comment:1 Changed 5 years ago by mabshoff

  • Milestone changed from sage-2.10 to sage-2.9.1

It looks like a newline at the end of the multi line expression of f(10) would fix the issue:

----------------------------------------------------------------------
| SAGE Version 2.9, Release Date: 2007-12-16                         |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------

sage: f = (exp(x)-1)/(exp(x/2)+1)
sage: g = exp(x/2)-1
sage: print f(10.0), g(10.0)
                               147.4131591025766                                147.4131591025766
sage: print 1, 2
1 2
sage: print f(10), g(10)
                                     10
                                    e   - 1
                                   --------
                                     5
                                    e  + 1                                       5
                                     e  - 1
sage: print f(10)
                                     10
                                    e   - 1
                                   --------
                                     5
                                    e  + 1
sage: print g(10)
                                      5
                                     e  - 1
sage:

Cheers,

Michael

Changed 5 years ago by was

comment:2 Changed 5 years ago by was

  • Summary changed from 2D terminal output is inconsistent and corrupted to [with patch; needs review] 2D terminal output is inconsistent and corrupted

comment:3 Changed 5 years ago by zimmerma

  • Summary changed from [with patch; needs review] 2D terminal output is inconsistent and corrupted to [with patch; with positive review] 2D terminal output is inconsistent and corrupted

[this is my first review, thus please take with care]

I get with this patch applied in 2.10:

sage: f=(exp(x)-1)/(exp(x/2)+1)
sage: g=exp(x/2)-1
sage: print f(10.0), g(10.0)

                               147.4131591025766 
                               147.4131591025766
sage: print 1, 2
1 2
sage: print f(10), g(10)

                                     10
                                    e   - 1
                                   --------
                                     5
                                    e  + 1 
                                      5
                                     e  - 1

The output is much better, but I would expect:

sage: print f(10.0), g(10.0)

                   147.4131591025766, 147.4131591025766

or

sage: print f(10.0), g(10.0)
147.4131591025766 147.4131591025766

However, since this is an improvement, I give a positive review.

comment:4 Changed 5 years ago by mabshoff

The potential solution to the adding an extra newlines in situations like

sage: print f(10.0), g(10.0)
147.4131591025766 147.4131591025766

might be that we need to check if the string returned from f(10.0 contains a newline in which case we need to add the extra newline to separate the the two multiline outputs. If that is doable please open another ticket.

Cheers,

Michael

comment:5 Changed 5 years ago by mabshoff

  • Status changed from new to closed
  • Resolution set to fixed

Merged in Sage 2.10.1.alpha1

Note: See TracTickets for help on using tickets.