From 0a8dfea4f58e2bbde8d469d0fd4ce9b2141b2da3 Mon Sep 17 00:00:00 2001 From: Yiheng Wang Date: Mon, 30 Dec 2024 09:21:48 +0000 Subject: [PATCH 1/2] mitigate issue Signed-off-by: Yiheng Wang --- tests/test_load_image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_load_image.py b/tests/test_load_image.py index a3e6d7bcfc..aa8b71b7fa 100644 --- a/tests/test_load_image.py +++ b/tests/test_load_image.py @@ -233,7 +233,7 @@ def test_nibabel_reader_gpu(self, input_param, filenames, expected_shape): input_param_cpu = input_param.copy() input_param_cpu["to_gpu"] = False result_cpu = LoadImage(image_only=True, **input_param_cpu)(filenames) - self.assertTrue(torch.equal(result_cpu, result.cpu())) + self.assertTrue(torch.allclose(result_cpu, result.cpu(), atol=1e-6)) @parameterized.expand([TEST_CASE_6, TEST_CASE_7, TEST_CASE_8, TEST_CASE_8_1, TEST_CASE_9]) def test_itk_reader(self, input_param, filenames, expected_shape): From ad6cda66688eaf978523421d8d7923674d0b0487 Mon Sep 17 00:00:00 2001 From: Yiheng Wang Date: Mon, 6 Jan 2025 05:26:55 +0000 Subject: [PATCH 2/2] use assert all close to check errors Signed-off-by: Yiheng Wang --- tests/test_load_image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_load_image.py b/tests/test_load_image.py index aa8b71b7fa..dc0af5e97e 100644 --- a/tests/test_load_image.py +++ b/tests/test_load_image.py @@ -233,7 +233,7 @@ def test_nibabel_reader_gpu(self, input_param, filenames, expected_shape): input_param_cpu = input_param.copy() input_param_cpu["to_gpu"] = False result_cpu = LoadImage(image_only=True, **input_param_cpu)(filenames) - self.assertTrue(torch.allclose(result_cpu, result.cpu(), atol=1e-6)) + assert_allclose(result_cpu, result.cpu(), atol=1e-6) @parameterized.expand([TEST_CASE_6, TEST_CASE_7, TEST_CASE_8, TEST_CASE_8_1, TEST_CASE_9]) def test_itk_reader(self, input_param, filenames, expected_shape):