You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to implement a class, which decides itself, which _repr_*_ it wants to use, because it is too expensive to calculate all _repr_*_ (xflr6/graphviz#138) and the default ordering is not good for that class.
It looks like this is not compatible with the idea of display, because the front end should decide.
But there is a workaround, the _ipython_display_ method.
When it is defined, the class can decide how to display.
Problem
The _ipython_display_ cannot distinguish between display and display_*.
So it always displays the same things, independent, if it was triggered by display_pretty or display_html.
Idea 1:
How about adding an argument, that indicate which format should be used and make a similar statement as _repr_mimebundle_:
The method should take keyword arguments include and exclude, though it is not required to respect them.
I am not sure, how difficult it is to implement this, because the code looks complicated.
To avoid a breaking change, a check of the signature would be necessary and then call it with zero or one argument.
It should not be too difficult to pass extra arguments, problem is that it might break previous user of IPython display if they don't accept *arg, **kwargs. We do rely on https://pypi.org/project/backcall/ already so we might be able to use that, or inspect the function signature.
You mention _repr_mimebundle_, any reason this does not work ?
Story
I tried to implement a class, which decides itself, which
_repr_*_
it wants to use, because it is too expensive to calculate all_repr_*_
(xflr6/graphviz#138) and the default ordering is not good for that class.It looks like this is not compatible with the idea of
display
, because the front end should decide.But there is a workaround, the
_ipython_display_
method.When it is defined, the class can decide how to display.
Problem
The
_ipython_display_
cannot distinguish betweendisplay
anddisplay_*
.So it always displays the same things, independent, if it was triggered by
display_pretty
ordisplay_html
.Idea 1:
How about adding an argument, that indicate which format should be used and make a similar statement as
_repr_mimebundle_
:I am not sure, how difficult it is to implement this, because the code looks complicated.
To avoid a breaking change, a check of the signature would be necessary and then call it with zero or one argument.
Idea 2:
Ignore
_ipython_display_
indisplay_*
.Example
The text was updated successfully, but these errors were encountered: