Conversation
5f1399c to
34b7edf
Compare
nulano
left a comment
There was a problem hiding this comment.
This should be very useful! Even if it takes a while until the changes reach Colab, it is not difficult to upgrade Pillow manually anyway.
src/PIL/ImageShow.py
Outdated
|
|
||
|
|
||
| try: | ||
| from IPython.display import display |
There was a problem hiding this comment.
| from IPython.display import display | |
| from IPython.display import display as _display |
Would it be reasonable to add a prefix to avoid confusion when using code completion tools? ImageShow.show and ImageShow.display are very similar and could be confusing to someone using it for the first time.
There was a problem hiding this comment.
Okay, sure. I went with ipython_display, to be even clearer.
| except ImportError: | ||
| pass | ||
| else: | ||
| register(IPythonViewer) |
There was a problem hiding this comment.
Any reason to put IPythonViewer before the unix viewers but after the other Windows/macOS ones? I think it would be best to put this at the top (or use register(..., order=0)) to help consistency in IPython (e.g. when combined with tools that offer PDF exports, etc.).
There was a problem hiding this comment.
Yep, no reason. I've moved it up.
| try: | ||
| viewer.get_command("test.jpg") | ||
| except NotImplementedError: | ||
| pass |
There was a problem hiding this comment.
| pass | |
| assert viewer.show(hopper()) == 1 |
Would remove the need for a separate test.
There was a problem hiding this comment.
The separate test
- confirms that the IPythonViewer is present when IPython is available
- runs IPythonViewer even if another Viewer instance has priority
Also, IPython seems to be a special case, where running its Viewer doesn't disrupt the test process - thinking generically for the sake of the future, just because a Viewer isn't based on a command line instruction doesn't mean that we want it to run in the middle of the test suite?
0706f1c to
55d3d26
Compare
| registered. It displays images on all IPython frontends. This will be helpful | ||
| to users of Google Colab, allowing ``im.show()`` to display images. | ||
|
|
||
| It is lower in priority than the other default Viewer instances, so it will |
There was a problem hiding this comment.
It is lower in priority than the other default Viewer instances
Please correct me if I'm wrong, but this is false. The new viewer has the highest priority AFAICT
There was a problem hiding this comment.
You're right! Thanks for catching that. However, the documentation correctly states my intention, so I've updated the code to match it.
Resolves #5286 by adding a new
ImageShow.Viewer-IPythonViewer. It calls thedisplay()method to allowImageShowto work with IPython... and Google Colab.Here is my demonstration of it working in Google Colab.
