Ticket #5836 (closed enhancement: fixed)

Opened 4 years ago

Last modified 4 years ago

[with patch, positive review] Make show() immediately show an image in the notebook

Reported by: jason Owned by: was
Priority: major Milestone: sage-3.4.2
Component: graphics Keywords:
Cc: was Work issues:
Report Upstream: Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description

The patch makes the cell containing:

show(plot(x^2, (x, -2,2)))
print "hi"

display the plot before printing "hi". This makes it much easier to construct nice-looking output.

William should get author credit on this one as well as me, since he showed how it could be done in a demo.

Attachments

trac-5836-show-html.patch Download (2.2 KB) - added by jason 4 years ago.

Change History

comment:1 Changed 4 years ago by jason

Well, unless William wants to review it.

In a sense, I reviewed his demo; I suppose he could review the actual patch.

A note about the patch: sage.misc.misc was imported twice in plot.py. I changed one of those imports to import the html function.

comment:2 Changed 4 years ago by jason

  • Cc was added
  • Summary changed from Make show() immediately show an image in the notebook to pwith patch, needs review] Make show() immediately show an image in the notebook

comment:3 Changed 4 years ago by was

  • Summary changed from pwith patch, needs review] Make show() immediately show an image in the notebook to pwith patch, needs work] Make show() immediately show an image in the notebook

Despite rumors to the contrary, there are several hundred doctests in the notebook directory, and your new code breaks two in cell.py, so post a patch that fixes those doctest breaks:

sage -t  devel/sage/sage/server/notebook/cell.py
**********************************************************************
File "/Users/wstein/build/sage-3.4.1.rc3/devel/sage-main/sage/server/notebook/cell.py", line 1751:
    sage: W.check_comp(wait=9999)
Expected:
    ('d', Cell 0; in=plot(sin(x),0,5), out=
    <BLANKLINE>
    )
Got:
    ('d', Cell 0; in=plot(sin(x),0,5), out=
    <html><font color='black'><img src='cell://sage0.png'></font></html>
    <BLANKLINE>
    )
**********************************************************************
File "/Users/wstein/build/sage-3.4.1.rc3/devel/sage-main/sage/server/notebook/cell.py", line 1777:
    sage: W.check_comp(wait=9999)
Expected:
    ('d', Cell 0; in=plot(sin(x),0,5), out=
    <BLANKLINE>
    )
Got:
    ('d', Cell 0; in=plot(sin(x),0,5), out=
    <html><font color='black'><img src='cell://sage0.png'></font></html>
    <BLANKLINE>
    )
**********************************************************************
2 items had failures:
   1 of  10 in __main__.example_80

Changed 4 years ago by jason

comment:4 Changed 4 years ago by jason

  • Summary changed from pwith patch, needs work] Make show() immediately show an image in the notebook to pwith patch, needs review] Make show() immediately show an image in the notebook

Patch redone to correct the doctests.

comment:5 Changed 4 years ago by jason

  • Summary changed from pwith patch, needs review] Make show() immediately show an image in the notebook to [with patch, needs review] Make show() immediately show an image in the notebook

comment:6 Changed 4 years ago by was

  • Summary changed from [with patch, needs review] Make show() immediately show an image in the notebook to [with patch, positive review] Make show() immediately show an image in the notebook

comment:7 Changed 4 years ago by mabshoff

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone changed from sage-4.0 to sage-3.4.2

Merged in Sage 3.4.2.alpha0.

Cheers,

Michael

Note: See TracTickets for help on using tickets.