add basic tests for Dim expansion and reduction and added imports

This commit is contained in:
2021-07-12 15:41:47 +02:00
parent 5468187e38
commit 54995658b8
2 changed files with 28 additions and 0 deletions

View File

@@ -1,3 +1,9 @@
import numpy as np
from PIL import Image, ImageDraw
from skimage import img_as_float
from skimage.feature import blob_dog
def extend_dim(array): def extend_dim(array):
ones = np.ones((array.shape[0], 1)) ones = np.ones((array.shape[0], 1))
return np.append(array, ones, axis=1) return np.append(array, ones, axis=1)

22
tests/test_situ_image.py Normal file
View File

@@ -0,0 +1,22 @@
from situr.image import extend_dim, remove_dim
import numpy as np
import unittest
class TestDimMethods(unittest.TestCase):
def test_identical_after_expand_remove_(self):
arr = np.random.rand(5, 2)
self.assertTrue(
np.array_equal(
arr, remove_dim(extend_dim(np.copy(arr)))
)
)
def test_extend_dim_only_extends(self):
arr = np.random.rand(5, 2)
self.assertTrue(
np.array_equal(
arr, extend_dim(np.copy(arr))[:, :-1]
)
)