[IPython-dev] [IPython-User] Runtime selection of the default pretty display

Aaron Meurer asmeurer at gmail.com
Sun Jun 1 21:30:59 EDT 2014


This sort of thing has come up in the context of SymPy before as well.
SymPy can render equations using MathJax, but it can also render them
as png using LaTeX itself (if it is installed). The notebook always
prefers MathJax to png, so the only way to force png output is to not
include the mathjax output, which is what
sympy.init_printing(use_latex='png') does. But this is obviously not
ideal (if something else pulls the latex off an object, it will think
that these objects don't have that representation). So I definitely
think there should be a way to change IPython's preferred order of
printing for different frontends.

Aaron Meurer

On Sun, Jun 1, 2014 at 3:42 PM, Akim Demaille <akim at lrde.epita.fr> wrote:
>
> Le 1 juin 2014 à 22:11, Matthias Bussonnier <bussonniermatthias at gmail.com> a écrit :
>
>> Hi Akim.
>
> hi!
>
>>>>> So what I'd like is a means to control which _repr_ IPython's
>>>>> display will chose.  Is there such a feature?
>>>>
>>>> No, there is not.
>>>
>>> Do you think that would be useful?
>>
>> No it is by design. If you need the functionality, you are probably misunderstanding the way it works.
>> As a library author you shouldn't decide for the user, if the user really want to change, he/she import
>> display_whatever from IPython.display and call it on your object. Any tentative to do something else,
>> will break things in weird ways.
>
> Well, I think I agree with what you are saying, but let me
> reemphasize that my problem here is rendering automata.
> Small automata should be rendered with _repr_svg_, bigger
> ones should just display some metrics by default, such as
> their size.  So I would have _repr_svg_ return None in such
> a case.  And that's a means to control which _repr_ will
> chose.  Except that it's decentralized: the logic of which
> _repr_ is 'enabled' is spread in each one of them.  As a
> library author I do not want to prevent what the user
> will see, I'm trying to provide them with the best _default_
> behavior possible.
>
> _repr_widget_ would be my best bet currently, as it allows
> me to select the best default behavior, and leave at the user
> the choice to select other formats.
>
> (And btw, I'm not pushing my users to call IPython.display
> at all, I'm really referring to the default display of values).
> _______________________________________________
> IPython-User mailing list
> IPython-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user



More information about the IPython-dev mailing list