From b0187d911bafa2fd0b53accd4ee26b2784357d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20=C5=BBak?= Date: Mon, 14 Mar 2022 16:38:43 +0100 Subject: [PATCH] fix #39 --- ipyplot/_img_helpers.py | 2 +- tests/test_plotting.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ipyplot/_img_helpers.py b/ipyplot/_img_helpers.py index c8c642b..000c64c 100644 --- a/ipyplot/_img_helpers.py +++ b/ipyplot/_img_helpers.py @@ -74,7 +74,7 @@ def _img_to_base64( Image as base64 string. """ # NOQA E501 # if statements to convert image to PIL.Image object - if type(image) is np.ndarray: + if isinstance(image, np.ndarray): if image.dtype in [np.float, np.float32, np.float64]: # if dtype is float and values range is from 0.0 to 1.0 # we need to normalize it to 0-255 range diff --git a/tests/test_plotting.py b/tests/test_plotting.py index b64754b..236bf00 100644 --- a/tests/test_plotting.py +++ b/tests/test_plotting.py @@ -1,6 +1,7 @@ import sys from typing import Sequence +import os import numpy as np import pandas as pd import pytest @@ -49,6 +50,8 @@ (LOCAL_URLS_AS_PIL, LABELS[1], LABELS[1]), (LOCAL_URLS_AS_PIL, LABELS[2], LABELS[2]), (LOCAL_URLS_AS_PIL, LABELS[3], LABELS[3]), + # test case for abs to rel path convertion + ([os.path.abspath(pth) for pth in BASE_LOCAL_URLS], LABELS[1], LABELS[0]), ]