From 78f8556e197e428205da21f154d7b1f149524fae Mon Sep 17 00:00:00 2001 From: Vasilis Vryniotis Date: Fri, 12 Feb 2021 09:19:14 +0000 Subject: [PATCH 1/3] Fix test flakiness caused by rounding. --- test/test_transforms.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_transforms.py b/test/test_transforms.py index b3d426e5221..a13492ecb70 100644 --- a/test/test_transforms.py +++ b/test/test_transforms.py @@ -1959,10 +1959,12 @@ def test_autoaugment(self): def test_random_erasing(self): img = torch.ones(3, 128, 128) - t = transforms.RandomErasing(scale=(0.1, 0.1), ratio=(1. / 3., 3. / 1.)) + t = transforms.RandomErasing(scale=(0.1, 0.1), ratio=(1. / 3., 3.)) y, x, h, w, v = t.get_params(img, t.scale, t.ratio, [t.value, ]) aspect_ratio = h / w - self.assertTrue(aspect_ratio > 1. / 3. and aspect_ratio < 3. / 1.) + # Add some tolerance due to the rounding and int conversion used in the transform + tol = 0.05 + self.assertTrue(1. / 3. - tol <= aspect_ratio <= 3. + tol, aspect_ratio) aspect_ratios = [] random.seed(42) From 54ed66dea011e911114cc56f96272abeeb4153c8 Mon Sep 17 00:00:00 2001 From: Vasilis Vryniotis Date: Fri, 12 Feb 2021 09:33:43 +0000 Subject: [PATCH 2/3] Update test/test_transforms.py Co-authored-by: Nicolas Hug --- test/test_transforms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_transforms.py b/test/test_transforms.py index a13492ecb70..a7c82d4a44e 100644 --- a/test/test_transforms.py +++ b/test/test_transforms.py @@ -1964,7 +1964,7 @@ def test_random_erasing(self): aspect_ratio = h / w # Add some tolerance due to the rounding and int conversion used in the transform tol = 0.05 - self.assertTrue(1. / 3. - tol <= aspect_ratio <= 3. + tol, aspect_ratio) + self.assertTrue(1. / 3. - tol <= aspect_ratio <= 3. + tol) aspect_ratios = [] random.seed(42) From 9ac7960d60cb361da45ce23f8145e51a5f2cd478 Mon Sep 17 00:00:00 2001 From: Vasilis Vryniotis Date: Fri, 12 Feb 2021 09:40:32 +0000 Subject: [PATCH 3/3] Styles --- test/test_transforms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_transforms.py b/test/test_transforms.py index a7c82d4a44e..8abf9e88db3 100644 --- a/test/test_transforms.py +++ b/test/test_transforms.py @@ -1959,12 +1959,12 @@ def test_autoaugment(self): def test_random_erasing(self): img = torch.ones(3, 128, 128) - t = transforms.RandomErasing(scale=(0.1, 0.1), ratio=(1. / 3., 3.)) + t = transforms.RandomErasing(scale=(0.1, 0.1), ratio=(1 / 3, 3.)) y, x, h, w, v = t.get_params(img, t.scale, t.ratio, [t.value, ]) aspect_ratio = h / w # Add some tolerance due to the rounding and int conversion used in the transform tol = 0.05 - self.assertTrue(1. / 3. - tol <= aspect_ratio <= 3. + tol) + self.assertTrue(1 / 3 - tol <= aspect_ratio <= 3 + tol) aspect_ratios = [] random.seed(42)