Skip to content

Commit 057ff4d

Browse files
committed
DCO Remediation Commit for R. Garcia-Dias <rafaelagd@gmail.com>
I, R. Garcia-Dias <rafaelagd@gmail.com>, hereby add my Signed-off-by to this commit: 8de64af I, R. Garcia-Dias <rafaelagd@gmail.com>, hereby add my Signed-off-by to this commit: 7c2ddb6 I, R. Garcia-Dias <rafaelagd@gmail.com>, hereby add my Signed-off-by to this commit: cfe5524 I, R. Garcia-Dias <rafaelagd@gmail.com>, hereby add my Signed-off-by to this commit: 1dec216 I, R. Garcia-Dias <rafaelagd@gmail.com>, hereby add my Signed-off-by to this commit: ec8bf1f Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>
1 parent 23f0290 commit 057ff4d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

tests/transforms/test_spacing.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,19 @@
2222
from monai.data.meta_tensor import MetaTensor
2323
from monai.data.utils import affine_to_spacing
2424
from monai.transforms import Spacing
25+
from monai.transforms.spatial.functional import _compiled_unsupported
2526
from monai.utils import fall_back_tuple
2627
from tests.lazy_transforms_utils import test_resampler_lazy
2728
from tests.test_utils import TEST_DEVICES, TEST_NDARRAYS_ALL, assert_allclose, dict_product, skip_if_quick
2829

29-
# Define the static parts of each test case
30-
_template_5_expected_output = (
31-
torch.tensor([[[[0.75, 0.75]], [[0.75, 0.75]], [[0.75, 0.75]]]])
32-
if USE_COMPILED
33-
else torch.tensor([[[[0.95527864, 0.95527864]], [[1.0, 1.0]], [[1.0, 1.0]]]])
34-
)
30+
_TEMPLATE_5_COMPILED = torch.tensor([[[[0.75, 0.75]], [[0.75, 0.75]], [[0.75, 0.75]]]])
31+
_TEMPLATE_5_NATIVE = torch.tensor([[[[0.95527864, 0.95527864]], [[1.0, 1.0]], [[1.0, 1.0]]]])
32+
33+
34+
def _template_5_expected_output(device: torch.device) -> torch.Tensor:
35+
if USE_COMPILED and not _compiled_unsupported(device):
36+
return _TEMPLATE_5_COMPILED
37+
return _TEMPLATE_5_NATIVE
3538

3639
all_template_parts = [
3740
[
@@ -241,6 +244,8 @@ def test_spacing(
241244

242245
test_resampler_lazy(tr, res, init_param=init_param, call_param=call_param)
243246

247+
if callable(expected_output):
248+
expected_output = expected_output(device)
244249
assert_allclose(res, expected_output, atol=1e-1, rtol=1e-1)
245250
sr = min(len(res.shape) - 1, 3)
246251
if isinstance(init_param["pixdim"], float):

0 commit comments

Comments
 (0)