Skip to content

Commit c0cfba6

Browse files
committed
Allow forgiving tolerance on some array comparision tests
This may have comes with the numpy 2 change where the precision of scalars is now preserved consistently. See https://numpy.org/devdocs/numpy_2_0_migration_guide.html#changes-to-numpy-data-type-promotion Observed testing results which failed only on the macOS runner: Mismatched elements: 1 / 1 (100%) Max absolute difference among violations: 2.74195588e-09 Max relative difference among violations: 3.36410326e-09 ACTUAL: array([0.815063], dtype=float32) DESIRED: array(0.815063)
1 parent f4def86 commit c0cfba6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/metrics/test_surface_dice.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def test_tolerance_euclidean_distance_with_spacing(self):
8282
expected_res0[1, 1] = np.nan
8383
for b, c in np.ndindex(batch_size, n_class):
8484
np.testing.assert_allclose(expected_res0[b, c], res0[b, c].cpu())
85-
np.testing.assert_array_equal(agg0.cpu(), np.nanmean(np.nanmean(expected_res0, axis=1), axis=0))
85+
np.testing.assert_allclose(agg0.cpu(), np.nanmean(np.nanmean(expected_res0, axis=1), axis=0))
8686
np.testing.assert_equal(not_nans.cpu(), torch.tensor(2))
8787

8888
def test_tolerance_euclidean_distance(self):
@@ -126,7 +126,7 @@ def test_tolerance_euclidean_distance(self):
126126
expected_res0[1, 1] = np.nan
127127
for b, c in np.ndindex(batch_size, n_class):
128128
np.testing.assert_allclose(expected_res0[b, c], res0[b, c].cpu())
129-
np.testing.assert_array_equal(agg0.cpu(), np.nanmean(np.nanmean(expected_res0, axis=1), axis=0))
129+
np.testing.assert_allclose(agg0.cpu(), np.nanmean(np.nanmean(expected_res0, axis=1), axis=0))
130130
np.testing.assert_equal(not_nans.cpu(), torch.tensor(2))
131131

132132
def test_tolerance_euclidean_distance_3d(self):
@@ -173,7 +173,7 @@ def test_tolerance_euclidean_distance_3d(self):
173173
expected_res0[1, 1] = np.nan
174174
for b, c in np.ndindex(batch_size, n_class):
175175
np.testing.assert_allclose(expected_res0[b, c], res0[b, c].cpu())
176-
np.testing.assert_array_equal(agg0.cpu(), np.nanmean(np.nanmean(expected_res0, axis=1), axis=0))
176+
np.testing.assert_allclose(agg0.cpu(), np.nanmean(np.nanmean(expected_res0, axis=1), axis=0))
177177
np.testing.assert_equal(not_nans.cpu(), torch.tensor(2))
178178

179179
def test_tolerance_all_distances(self):

0 commit comments

Comments
 (0)