nxpd icon indicating copy to clipboard operation
nxpd copied to clipboard

Suggestions on IPython integration

Open rainwoodman opened this issue 10 years ago • 6 comments

Wonder if you are interested to migrate the ipyhon intergration to something similar to

https://github.com/rainwoodman/nxsvg/blob/master/src/nxsvg.py#L532

This would get rid of the conditional import in draw_pydot.

rainwoodman avatar Jan 11 '15 00:01 rainwoodman

I like it. Do you know if it is easy to specify a priority for the various repr functions? I can imagine that some people might have large graphs and aren't so interested in visualizing them. In those cases, the original repr is better for feedback and it'd be nice to provide a convenient way for people to disable this behavior.

chebee7i avatar Jan 16 '15 16:01 chebee7i

But I remember if a repr_xxx function returns None, Ipython would silently ignore it. If repr_xxx raises an exception, the exception would be issued in the notebook as a warning, and the function is ignored. The final fallback is repr .

For large graphs, we can leave a module-wide parameter for the threshold size of a graph that would be visualized. If the graph is too large, raise a ValueError or something so that the default repr is used.

Enabling and disabling the hook via a dictionary entry is probably not the most convenient API -- after all it takes some 'action' to enable the display hook than a 'configuration'.

For example, in mpld3, the setup is done as a function:

https://mpld3.github.io/modules/API.html#mpld3.enable_notebook https://mpld3.github.io/modules/API.html#mpld3.disable_notebook

The additional setup parameters are passed (for example the threshold) as **kwargs.

rainwoodman avatar Jan 17 '15 02:01 rainwoodman

That all sounds good.

chebee7i avatar Jan 25 '15 03:01 chebee7i

Sure. I will look into this later of the week.

rainwoodman avatar Jan 28 '15 18:01 rainwoodman

@rainwoodman Have you had the opportunity put together an implementation for this? No worries if not.

chebee7i avatar Feb 16 '15 17:02 chebee7i

Sorry it fell behind my todo list! Here is a basic version (not yet confirming to the enable/disable api) in issue #6

rainwoodman avatar Feb 17 '15 01:02 rainwoodman