On Thursday, April 30, 2015 at 8:19:39 AM UTC+2, Martin R wrote:
>
> I'm only trying to understand.  Yes, I assume it happens that someone is 
> using sage as a python library and then possibly only wants repr.
>

If you use Sage as a Python library then you are in control of the 
displayhook. The Python default which will only use __repr__. Your 
application can change that of course.


So the point really is that, at least for me personally, having rich_repr 
>>> return graphics in the console (for any object, not only graphs) is very 
>>> very undesirable.
>>>
>> Presumably you find it desirable to display Graphics() objects (the 
>> return value of plot()) as picture, so there is that.
>>
> Of course.  Hence, _rich_repr_ (or _repr_) should not return a Graphics 
> object, right?.
>

Graphics() is the base class for (2d) graphics in Sage. It does more than 
just draw pictures, you can also save them in different image file formats, 
play with axes, etc. The _rich_repr_() method never returns Graphics, it 
uses its own class hierarchy to encapsulate a particular type of rich 
output that is supported by the backend.

sage: p = plot(sin)
sage: type(p)
<class 'sage.plot.graphics.Graphics'>

sage: p_repr = p.__repr__()
sage: type(p_repr)
<type 'str'>

sage: dm = sage.repl.rich_output.get_display_manager()
sage: p_rich_repr = p._rich_repr_(dm)
sage: type(p_rich_repr)
<class 'sage.repl.rich_output.output_graphics.OutputImagePng'>

sage: dm.preferences.graphics = 'vector'
sage: type(p._rich_repr_(dm))
<class 'sage.repl.rich_output.output_graphics.OutputImagePdf'>

sage: dm.supported_output()
frozenset({<class 'sage.repl.rich_output.output_basic.OutputPlainText'>,
           <class 'sage.repl.rich_output.output_basic.OutputAsciiArt'>,
           <class 'sage.repl.rich_output.output_basic.OutputLatex'>,
           <class 'sage.repl.rich_output.output_graphics.OutputImagePng'>,
           <class 'sage.repl.rich_output.output_graphics.OutputImageGif'>,
           <class 'sage.repl.rich_output.output_graphics.OutputImagePdf'>,
           <class 'sage.repl.rich_output.output_graphics.OutputImageDvi'>,
           <class 
'sage.repl.rich_output.output_graphics3d.OutputSceneJmol'>,
           <class 
'sage.repl.rich_output.output_graphics3d.OutputSceneWavefront'>})

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to