Opened 7 years ago

Closed 7 years ago

#16270 closed task (duplicate)

Ipython notebook

Reported by: elixyre Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: notebook Keywords: ipython, latex, display
Cc: nthiery, vbraun, jason, timdumol, was, kcrisman Merged in:
Authors: Reviewers: Jean-Baptiste Priez
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: #16444 Stopgaps:

Status badges


The ipython notebook is a very pleasant tool. I would like to use sage notebook methods to produce image in the ipython notebook?

In particular, I would like to know how the sage notebook do that.

At the end, I would like to use the ipython tools which try to find a *_repr_foo_* method.

from IPython.display import Image

class myObject(SageObject):

    def _repr_png_(self):
        f = produce_a_file_with_the_sage_notebook_tools(self, ...)
        return Image(f).data

I made some tests:

from IPython.display import Image
file = "/Users/elix/img.png"
def _repr_png_(self):
    latex.eval(latex(self), locals(), filename=file)
    return Image(filename=file, format='png').data

BinaryTree._repr_png_ = _repr_png_


that produces


e = (1 - sqrt(1 - 4*x)) / (2*x)
latex.eval(latex(e), locals(), filename=file)

will produce an error... so that is not the good way...

Change History (7)

comment:1 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:2 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:3 Changed 7 years ago by kcrisman

Is this a duplicate of #16444?

comment:4 Changed 7 years ago by vbraun

  • Dependencies set to #16444

Well I don't know if latex is going to work right away... I propose you'll try after #16444 hits and we'll take it from there.

comment:5 Changed 7 years ago by kcrisman

  • Authors Jean-Baptiste Priez deleted
  • Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
  • Reviewers set to Jean-Baptiste Priez
  • Status changed from new to needs_review

According to this comment by the reporter of this ticket, this is a duplicate of #16444. I'll let him confirm that.

comment:6 Changed 7 years ago by elixyre

  • Status changed from needs_review to positive_review

comment:7 Changed 7 years ago by vbraun

  • Resolution set to duplicate
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.