From 258a61f1a5df5f8f7dcf3ed1e9db8d54fd0d59be Mon Sep 17 00:00:00 2001 From: Peter Parente Date: Wed, 1 Jan 2025 12:40:54 -0500 Subject: [PATCH] fix: prettier lost indents --- .../index.md | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/pages/20191112-jupyter-tidbit-image-gallery/index.md b/pages/20191112-jupyter-tidbit-image-gallery/index.md index 80f65cf..8bec1b3 100644 --- a/pages/20191112-jupyter-tidbit-image-gallery/index.md +++ b/pages/20191112-jupyter-tidbit-image-gallery/index.md @@ -48,44 +48,44 @@ on the screen at once and spot coarse differences.
In [1]:
-
from IPython.display import HTML, Image
+
+
from IPython.display import HTML, Image
 
 def _src_from_data(data):
-"""Base64 encodes image bytes for inclusion in an HTML img element"""
-img_obj = Image(data=data)
-for bundle in img_obj.\_repr_mimebundle_():
-for mimetype, b64value in bundle.items():
-if mimetype.startswith('image/'):
-return f'data:{mimetype};base64,{b64value}'
+    """Base64 encodes image bytes for inclusion in an HTML img element"""
+    img_obj = Image(data=data)
+    for bundle in img_obj.\_repr_mimebundle_():
+        for mimetype, b64value in bundle.items():
+            if mimetype.startswith('image/'):
+                return f'data:{mimetype};base64,{b64value}'
 
 def gallery(images, row_height='auto'):
-"""Shows a set of images in a gallery that flexes with the width of the notebook.
- 
- Parameters
- ----------
- images: list of str or bytes
- URLs or bytes of images to display
-
- row_height: str
- CSS height value to assign to all images. Set to 'auto' by default to show images
- with their native dimensions. Set to a value like '250px' to make all rows
- in the gallery equal height.
- """
-figures = []
-for image in images:
-if isinstance(image, bytes):
-src = \_src_from_data(image)
-caption = ''
-else:
-src = image
-caption = f'<figcaption style="font-size: 0.6em">{image}</figcaption>'
-figures.append(f'''
+    """Shows a set of images in a gallery that flexes with the width of the notebook.
+     
+     Parameters
+     ----------
+     images: list of str or bytes
+         URLs or bytes of images to display
+     row_height: str
+         CSS height value to assign to all images. Set to 'auto' by default to show images
+         with their native dimensions. Set to a value like '250px' to make all rows
+         in the gallery equal height.
+     """
+    figures = []
+    for image in images:
+        if isinstance(image, bytes):
+            src = \_src_from_data(image)
+            caption = ''
+        else:
+            src = image
+            caption = f'<figcaption style="font-size: 0.6em">{image}</figcaption>'
+        figures.append(f'''
  <figure style="margin: 5px !important;">
  <img src="{src}" style="height: {row_height}">
  {caption}
  </figure>
  ''')
-return HTML(data=f'''
+    return HTML(data=f'''
  <div style="display: flex; flex-flow: row wrap; text-align: center;">
  {''.join(figures)}
  </div>
@@ -123,9 +123,9 @@ on the screen at once and spot coarse differences.
 
 urls = []
 for i in range(25):
-width = random.randrange(400, 800)
-height = random.randrange(400, 800)
-urls.append(f'https://picsum.photos/{width}/{height}?random={i}')
+    width = random.randrange(400, 800)
+    height = random.randrange(400, 800)
+    urls.append(f'https://picsum.photos/{width}/{height}?random={i}')
 
 
@@ -320,9 +320,9 @@ on the screen at once and spot coarse differences. pngs = [] for i in range(50): -buffer = io.BytesIO() -pagan.Avatar(f'{i}').img.save(buffer, 'png') -pngs.append(buffer.getvalue()) + buffer = io.BytesIO() + pagan.Avatar(f'{i}').img.save(buffer, 'png') + pngs.append(buffer.getvalue())