Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 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, padder=padder, mode=mode, allow_missing_keys=allow_missing_keys, lazy=lazy)


class BorderPadd(Padd):
Expand Down Expand Up @@ -274,9 +273,8 @@ 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, padder=padder, mode=mode, allow_missing_keys=allow_missing_keys, lazy=lazy)


class DivisiblePadd(Padd):
Expand Down Expand Up @@ -324,9 +322,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, padder=padder, mode=mode, allow_missing_keys=allow_missing_keys, lazy=lazy)


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