From 45404c92edb77f6eec968f8394da69b89b9f7a6b Mon Sep 17 00:00:00 2001
From: osmala <ossi.laine@utu.fi>
Date: Fri, 22 May 2020 11:33:38 +0300
Subject: [PATCH] Error handling to test function

---
 plot_image.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/plot_image.py b/plot_image.py
index ad355fd..a636ff4 100644
--- a/plot_image.py
+++ b/plot_image.py
@@ -46,7 +46,12 @@ def show_images(images, cols=1, titles=None):
     """
 
     # default embody image for the background
-    default_img = plt.imread("./dummy_600.png")
+
+    try:
+        background = True
+        default_img = plt.imread("./dummy_600.png")
+    except FileNotFoundError:
+        background = False
 
     # get a copy of the gray color map
     my_cmap = copy.copy(plt.cm.get_cmap('gray'))
@@ -67,7 +72,8 @@ def show_images(images, cols=1, titles=None):
         plt.imshow(image, cmap=my_cmap)
 
         # draw default background image with transparency on top of the points
-        plt.imshow(default_img, extent=[0, 200, 600, 0], alpha=0.33)
+        if background:
+            plt.imshow(default_img, extent=[0, 200, 600, 0], alpha=0.33)
 
         a.set_title(title)
 
-- 
GitLab