Skip to content

Changing Jupyter plain text output on every cell run #5890

@shamrin

Description

@shamrin

What did you do?

I'm using Pillow to generate simple images in Jupyter environment:

from PIL import Image
Image.frombuffer('RGB', (16,16), bytes([100]*(16*16)))

It works nicely!

image

What did you expect to happen?

I expect every run of the cell produce the same output in the notebook file, to avoid needless changes in Git.

What actually happened?

Every run produces different hash in text representation of the output. For example: at 0x1075D8370.

$ git diff test.ipynb 
diff --git a/test.ipynb b/test.ipynb
index f769d4b..a4dd8af 100644
--- a/test.ipynb
+++ b/test.ipynb
@@ -9,7 +9,7 @@
      "data": {
       "image/png": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAGUlEQVR4nGPc62fCQApgIkn1qIZRDUNKAwADRwFfBBwAnwAAAABJRU5ErkJggg==",
       "text/plain": [
-       "<PIL.Image.Image image mode=RGB size=16x16 at 0x1075D8370>"
+       "<PIL.Image.Image image mode=RGB size=16x16 at 0x108C50160>"
       ]
      },
      "execution_count": 1,

Compare with Matplotlib output:

     "data": {
      "image/png": "...",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     }

What are your OS, Python and Pillow versions?

  • OS: Mac OS 10.15.6
  • Python: 3.9.8
  • Pillow: 8.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions