From ed6adb2ad5625589a5a71c1dd2ff149819afa6e0 Mon Sep 17 00:00:00 2001 From: Thomas BAUDIER Date: Thu, 31 Oct 2024 16:41:30 +0100 Subject: [PATCH] With numpy>2.0 need to change float32 to float64 to have a consistent hash between numpy version --- gatetools/image_uncertainty.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gatetools/image_uncertainty.py b/gatetools/image_uncertainty.py index b344b49..297074f 100644 --- a/gatetools/image_uncertainty.py +++ b/gatetools/image_uncertainty.py @@ -202,9 +202,9 @@ def test_image_uncertainty(self): xx, yy, zz = np.meshgrid(x, y, z) npImage = 10*xx+4.5 npsImage = 10*xx**2+9*xx+2.85 - image = itk.image_from_array(np.float32(npImage)) + image = itk.image_from_array(np.float64(npImage)) images = [image] - simage = itk.image_from_array(np.float32(npsImage)) + simage = itk.image_from_array(np.float64(npsImage)) simages = [simage] uncertainty = image_uncertainty(images, simages, N=1000000000000) tmpdirpath = tempfile.mkdtemp() @@ -212,8 +212,8 @@ def test_image_uncertainty(self): with open(os.path.join(tmpdirpath, "uncertainty.mha"),"rb") as fnew: bytesNew = fnew.read() new_hash = hashlib.sha256(bytesNew).hexdigest() - self.assertTrue("0a2dc7a0e28509c569cecde6b6252507936b29365cb4db0c75ab3c0fab3b2bc4" == new_hash) - shutil.rmtree(tmpdirpath) + self.assertTrue("0e1f8e0f0d7d7d3921c726dc33409345e6d9b8bfcc53b797d67f8b48997fa1a5" == new_hash) + print(tmpdirpath) def test_image_uncertainty_by_slice(self): x = np.arange(0, 1, 0.01) y = np.arange(0, 1, 0.01) @@ -221,9 +221,9 @@ def test_image_uncertainty_by_slice(self): xx, yy, zz = np.meshgrid(x, y, z) npImage = 10*xx+4.5 npsImage = 10*xx**2+9*xx+2.85 - image = itk.image_from_array(np.float32(npImage)) + image = itk.image_from_array(np.float64(npImage)) images = [image] - simage = itk.image_from_array(np.float32(npsImage)) + simage = itk.image_from_array(np.float64(npsImage)) simages = [simage] uncertainty, mean, nb = image_uncertainty_by_slice(images, simages, N=1000000000000) tmpdirpath = tempfile.mkdtemp() @@ -234,7 +234,7 @@ def test_image_uncertainty_by_slice(self): with open(os.path.join(tmpdirpath, "uncertainty.mha"),"rb") as fnew: bytesNew = fnew.read() new_hash = hashlib.sha256(bytesNew).hexdigest() - self.assertTrue("0a2dc7a0e28509c569cecde6b6252507936b29365cb4db0c75ab3c0fab3b2bc4" == new_hash) + self.assertTrue("0e1f8e0f0d7d7d3921c726dc33409345e6d9b8bfcc53b797d67f8b48997fa1a5" == new_hash) shutil.rmtree(tmpdirpath) def test_image_uncertainty_Poisson(self): x = np.arange(0, 1, 0.01)