Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: YunLiu <[email protected]>
  • Loading branch information
KumoLiu committed Dec 13, 2023
1 parent b1c8b42 commit 3611f07
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 4 additions & 6 deletions monai/transforms/croppad/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,8 @@ def __init__(
note that `np.pad` treats channel dimension as the first dimension.
"""
LazyTransform.__init__(self, lazy)
padder = SpatialPad(spatial_size, method, lazy=lazy, **kwargs)
Padd.__init__(self, keys, padder=padder, mode=mode, allow_missing_keys=allow_missing_keys)
Padd.__init__(self, keys, lazy=lazy, padder=padder, mode=mode, allow_missing_keys=allow_missing_keys)


class BorderPadd(Padd):
Expand Down Expand Up @@ -274,9 +273,9 @@ def __init__(
note that `np.pad` treats channel dimension as the first dimension.
"""
LazyTransform.__init__(self, lazy)
padder = BorderPad(spatial_border=spatial_border, lazy=lazy, **kwargs)
Padd.__init__(self, keys, padder=padder, mode=mode, allow_missing_keys=allow_missing_keys)
Padd.__init__(self, keys, lazy=lazy, padder=padder, mode=mode, allow_missing_keys=allow_missing_keys)
# Padd.__init__(self, keys, padder=padder, mode=mode, allow_missing_keys=allow_missing_keys)


class DivisiblePadd(Padd):
Expand Down Expand Up @@ -324,9 +323,8 @@ def __init__(
See also :py:class:`monai.transforms.SpatialPad`
"""
LazyTransform.__init__(self, lazy)
padder = DivisiblePad(k=k, method=method, lazy=lazy, **kwargs)
Padd.__init__(self, keys, padder=padder, mode=mode, allow_missing_keys=allow_missing_keys)
Padd.__init__(self, keys, lazy=lazy, padder=padder, mode=mode, allow_missing_keys=allow_missing_keys)


class Cropd(MapTransform, InvertibleTransform, LazyTransform):
Expand Down
3 changes: 3 additions & 0 deletions tests/padders.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ def pad_test_pending_ops(self, input_param, input_shape):
# TODO: mode="bilinear" may report error
overrides = {"mode": "nearest", "padding_mode": mode[1], "align_corners": False}
result = apply_pending(pending_result, overrides=overrides)[0]
# lazy in constructor
pad_fn_lazy = self.Padder(mode=mode[0], lazy=True, **input_param)
self.assertTrue(pad_fn_lazy.lazy)
# compare
assert_allclose(result, expected, rtol=1e-5)
if isinstance(result, MetaTensor) and not isinstance(pad_fn, MapTransform):
Expand Down

0 comments on commit 3611f07

Please sign in to comment.