From 4d89402ec91a06afddfb3dc91cb061e27c07e641 Mon Sep 17 00:00:00 2001 From: Behrooz <3968947+behxyz@users.noreply.github.com> Date: Wed, 31 Mar 2021 15:56:48 -0400 Subject: [PATCH] Update pathology unittests Signed-off-by: Behrooz <3968947+behxyz@users.noreply.github.com> --- tests/test_cuimage_reader.py | 4 +-- tests/test_masked_inference_wsi_dataset.py | 38 ++++++++++++---------- tests/test_openslide_reader.py | 2 +- tests/test_patch_wsi_dataset.py | 2 +- tests/test_smartcache_patch_wsi_dataset.py | 2 +- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/tests/test_cuimage_reader.py b/tests/test_cuimage_reader.py index 1b0293f159..c096bad0c2 100644 --- a/tests/test_cuimage_reader.py +++ b/tests/test_cuimage_reader.py @@ -14,7 +14,7 @@ PILImage, has_pil = optional_import("PIL.Image") FILE_URL = "http://openslide.cs.cmu.edu/download/openslide-testdata/Generic-TIFF/CMU-1.tiff" -FILE_PATH = os.path.join(os.path.dirname(__file__), "testing_data", os.path.basename(FILE_URL)) +FILE_PATH = os.path.join(os.path.dirname(__file__), "testing_data", "temp_" + os.path.basename(FILE_URL)) HEIGHT = 32914 WIDTH = 46000 @@ -105,7 +105,7 @@ def test_read_rgba(self, img_expected): image = {} reader = WSIReader("cuCIM") for mode in ["RGB", "RGBA"]: - file_path = self.create_rgba_image(img_expected, "test_cu_tiff_image", mode=mode) + file_path = self.create_rgba_image(img_expected, "temp_cu_tiff_image", mode=mode) img_obj = reader.read(file_path) image[mode], _ = reader.get_data(img_obj) diff --git a/tests/test_masked_inference_wsi_dataset.py b/tests/test_masked_inference_wsi_dataset.py index 7c8a815c2e..88af8c05c0 100644 --- a/tests/test_masked_inference_wsi_dataset.py +++ b/tests/test_masked_inference_wsi_dataset.py @@ -15,11 +15,13 @@ _, has_osl = optional_import("openslide") FILE_URL = "http://openslide.cs.cmu.edu/download/openslide-testdata/Generic-TIFF/CMU-1.tiff" -FILE_PATH = os.path.join(os.path.dirname(__file__), "testing_data", os.path.basename(FILE_URL)) +base_name, extension = os.path.splitext(os.path.basename(FILE_URL)) +FILE_NAME = "temp_" + base_name +FILE_PATH = os.path.join(os.path.dirname(__file__), "testing_data", FILE_NAME + extension) -MASK1 = os.path.join(os.path.dirname(__file__), "testing_data", "tissue_mask1.npy") -MASK2 = os.path.join(os.path.dirname(__file__), "testing_data", "tissue_mask2.npy") -MASK4 = os.path.join(os.path.dirname(__file__), "testing_data", "tissue_mask4.npy") +MASK1 = os.path.join(os.path.dirname(__file__), "testing_data", "temp_tissue_mask1.npy") +MASK2 = os.path.join(os.path.dirname(__file__), "testing_data", "temp_tissue_mask2.npy") +MASK4 = os.path.join(os.path.dirname(__file__), "testing_data", "temp_tissue_mask4.npy") HEIGHT = 32914 WIDTH = 46000 @@ -47,7 +49,7 @@ def prepare_data(): [ { "image": np.array([[[243]], [[243]], [[243]]], dtype=np.uint8), - "name": "CMU-1", + "name": FILE_NAME, "mask_location": [100, 100], }, ], @@ -62,12 +64,12 @@ def prepare_data(): [ { "image": np.array([[[243]], [[243]], [[243]]], dtype=np.uint8), - "name": "CMU-1", + "name": FILE_NAME, "mask_location": [100, 100], }, { "image": np.array([[[243]], [[243]], [[243]]], dtype=np.uint8), - "name": "CMU-1", + "name": FILE_NAME, "mask_location": [101, 100], }, ], @@ -82,22 +84,22 @@ def prepare_data(): [ { "image": np.array([[[243]], [[243]], [[243]]], dtype=np.uint8), - "name": "CMU-1", + "name": FILE_NAME, "mask_location": [100, 100], }, { "image": np.array([[[243]], [[243]], [[243]]], dtype=np.uint8), - "name": "CMU-1", + "name": FILE_NAME, "mask_location": [100, 101], }, { "image": np.array([[[243]], [[243]], [[243]]], dtype=np.uint8), - "name": "CMU-1", + "name": FILE_NAME, "mask_location": [101, 100], }, { "image": np.array([[[243]], [[243]], [[243]]], dtype=np.uint8), - "name": "CMU-1", + "name": FILE_NAME, "mask_location": [101, 101], }, ], @@ -121,7 +123,7 @@ def prepare_data(): ], dtype=np.uint8, ), - "name": "CMU-1", + "name": FILE_NAME, "mask_location": [100, 100], }, ], @@ -139,17 +141,17 @@ def prepare_data(): [ { "image": np.array([[[243]], [[243]], [[243]]], dtype=np.uint8), - "name": "CMU-1", + "name": FILE_NAME, "mask_location": [100, 100], }, { "image": np.array([[[243]], [[243]], [[243]]], dtype=np.uint8), - "name": "CMU-1", + "name": FILE_NAME, "mask_location": [100, 100], }, { "image": np.array([[[243]], [[243]], [[243]]], dtype=np.uint8), - "name": "CMU-1", + "name": FILE_NAME, "mask_location": [101, 100], }, ], @@ -167,7 +169,7 @@ def prepare_data(): [ { "image": np.array([[[243]], [[243]], [[243]]], dtype=np.uint8), - "name": "CMU-1", + "name": FILE_NAME, "mask_location": [100, 100], }, ], @@ -182,12 +184,12 @@ def prepare_data(): [ { "image": np.array([[[243]], [[243]], [[243]]], dtype=np.uint8), - "name": "CMU-1", + "name": FILE_NAME, "mask_location": [100, 100], }, { "image": np.array([[[243]], [[243]], [[243]]], dtype=np.uint8), - "name": "CMU-1", + "name": FILE_NAME, "mask_location": [101, 100], }, ], diff --git a/tests/test_openslide_reader.py b/tests/test_openslide_reader.py index ca50cec4de..e005dbd1c4 100644 --- a/tests/test_openslide_reader.py +++ b/tests/test_openslide_reader.py @@ -14,7 +14,7 @@ FILE_URL = "http://openslide.cs.cmu.edu/download/openslide-testdata/Generic-TIFF/CMU-1.tiff" -FILE_PATH = os.path.join(os.path.dirname(__file__), "testing_data", os.path.basename(FILE_URL)) +FILE_PATH = os.path.join(os.path.dirname(__file__), "testing_data", "temp_" + os.path.basename(FILE_URL)) HEIGHT = 32914 WIDTH = 46000 diff --git a/tests/test_patch_wsi_dataset.py b/tests/test_patch_wsi_dataset.py index d030671d06..c4a94a60c4 100644 --- a/tests/test_patch_wsi_dataset.py +++ b/tests/test_patch_wsi_dataset.py @@ -14,7 +14,7 @@ _, has_osl = optional_import("openslide") FILE_URL = "http://openslide.cs.cmu.edu/download/openslide-testdata/Generic-TIFF/CMU-1.tiff" -FILE_PATH = os.path.join(os.path.dirname(__file__), "testing_data", os.path.basename(FILE_URL)) +FILE_PATH = os.path.join(os.path.dirname(__file__), "testing_data", "temp_" + os.path.basename(FILE_URL)) TEST_CASE_0 = [ { diff --git a/tests/test_smartcache_patch_wsi_dataset.py b/tests/test_smartcache_patch_wsi_dataset.py index a7c90b5205..d7c2ce5bd1 100644 --- a/tests/test_smartcache_patch_wsi_dataset.py +++ b/tests/test_smartcache_patch_wsi_dataset.py @@ -13,7 +13,7 @@ _, has_cim = optional_import("cucim") FILE_URL = "http://openslide.cs.cmu.edu/download/openslide-testdata/Generic-TIFF/CMU-1.tiff" -FILE_PATH = os.path.join(os.path.dirname(__file__), "testing_data", os.path.basename(FILE_URL)) +FILE_PATH = os.path.join(os.path.dirname(__file__), "testing_data", "temp_" + os.path.basename(FILE_URL)) TEST_CASE_0 = [ {