Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pretty_print clobbers _ (history) #9683

Closed
mguaypaq opened this issue Aug 4, 2010 · 9 comments
Closed

pretty_print clobbers _ (history) #9683

mguaypaq opened this issue Aug 4, 2010 · 9 comments

Comments

@mguaypaq
Copy link
Contributor

mguaypaq commented Aug 4, 2010

After using pretty_print, the first history variable (_) no longer updates.

----------------------------------------------------------------------
| Sage Version 4.5.1, Release Date: 2010-07-19                       |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
Loading Sage library. Current Mercurial branch is: combinat
sage: 17
17
sage: _
17
sage: 23
23
sage: _
23
sage: pretty_print(17)
<html><span class="math">\newcommand{\Bold}[1]{\mathbf{#1}}17</span></html>
sage: _
17
sage: 23
23
sage: _
17

The relevant function seems to be pretty_print in /sage/misc/latex.py, but I don't know the right way to fix it. The function and pretty_print_default in same file, and the functions displayhook and install in /sage/misc/displayhook.py may also be relevant.

CC: @mwhansen

Component: user interface

Keywords: pretty_print, history, days57

Author: Mike Hansen

Branch/Commit: 3cc45a8

Reviewer: Volker Braun

Issue created by migration from https://trac.sagemath.org/ticket/9683

@gvol
Copy link

gvol commented Nov 25, 2012

comment:1

In the ipython displayhook it checks to see if underscore was set explicitly and if so, it stops tracking. We are setting it explicitly in pretty_print. Maybe if we just stop doing this it will work. Also we probably need to fix pretty_print_default to set it to the ipython displayhook instead of the default one.

    def check_for_underscore(self):
        """Check if the user has set the '_' variable by hand."""
        # If something injected a '_' variable in __builtin__, delete
        # ipython's automatic one so we don't clobber that.  gettext() in
        # particular uses _, so we need to stay away from it.
        if '_' in __builtin__.__dict__:
            try:
                del self.shell.user_ns['_']
            except KeyError:
                pass

@mwhansen
Copy link
Contributor

comment:2

Attachment: trac_9683.patch.gz

I've posted a patch. It doesn't have a test for this problem. I could make one, but it's slightly annoying since you have to do everything indirectly through an IPython shell object.

@mwhansen
Copy link
Contributor

Author: Mike Hansen

@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@vbraun
Copy link
Member

vbraun commented Apr 10, 2014

@vbraun
Copy link
Member

vbraun commented Apr 10, 2014

New commits:

3cc45a8#9683: pretty_print clobbers _ (history)

@vbraun
Copy link
Member

vbraun commented Apr 10, 2014

Commit: 3cc45a8

@vbraun
Copy link
Member

vbraun commented Apr 10, 2014

Changed keywords from pretty_print, history to pretty_print, history, days57

@vbraun
Copy link
Member

vbraun commented Apr 10, 2014

Reviewer: Volker Braun

@vbraun
Copy link
Member

vbraun commented Apr 13, 2014

Changed branch from u/vbraun/pretty_print_clobbers____history_ to 3cc45a8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants