Skip to content
Open
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
12 changes: 6 additions & 6 deletions monai/transforms/croppad/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class Pad(InvertibleTransform, LazyTransform):

def __init__(
self,
to_pad: tuple[tuple[int, int]] | None = None,
to_pad: Sequence[tuple[int, int]] | None = None,
mode: str = PytorchPadMode.CONSTANT,
lazy: bool = False,
**kwargs,
Expand All @@ -118,7 +118,7 @@ def __init__(
self.mode = mode
self.kwargs = kwargs

def compute_pad_width(self, spatial_shape: Sequence[int]) -> tuple[tuple[int, int]]:
def compute_pad_width(self, spatial_shape: Sequence[int]) -> tuple[tuple[int, int], ...]:
"""
dynamically compute the pad width according to the spatial shape.
the output is the amount of padding for all dimensions including the channel.
Expand All @@ -132,7 +132,7 @@ def compute_pad_width(self, spatial_shape: Sequence[int]) -> tuple[tuple[int, in
def __call__( # type: ignore[override]
self,
img: torch.Tensor,
to_pad: tuple[tuple[int, int]] | None = None,
to_pad: Sequence[tuple[int, int]] | None = None,
mode: str | None = None,
lazy: bool | None = None,
**kwargs,
Expand Down Expand Up @@ -218,7 +218,7 @@ def __init__(
self.method: Method = look_up_option(method, Method)
super().__init__(mode=mode, lazy=lazy, **kwargs)

def compute_pad_width(self, spatial_shape: Sequence[int]) -> tuple[tuple[int, int]]:
def compute_pad_width(self, spatial_shape: Sequence[int]) -> tuple[tuple[int, int], ...]:
"""
dynamically compute the pad width according to the spatial shape.

Expand Down Expand Up @@ -273,7 +273,7 @@ def __init__(
self.spatial_border = spatial_border
super().__init__(mode=mode, lazy=lazy, **kwargs)

def compute_pad_width(self, spatial_shape: Sequence[int]) -> tuple[tuple[int, int]]:
def compute_pad_width(self, spatial_shape: Sequence[int]) -> tuple[tuple[int, int], ...]:
spatial_border = ensure_tuple(self.spatial_border)
if not all(isinstance(b, int) for b in spatial_border):
raise ValueError(f"self.spatial_border must contain only ints, got {spatial_border}.")
Expand Down Expand Up @@ -336,7 +336,7 @@ def __init__(
self.method: Method = Method(method)
super().__init__(mode=mode, lazy=lazy, **kwargs)

def compute_pad_width(self, spatial_shape: Sequence[int]) -> tuple[tuple[int, int]]:
def compute_pad_width(self, spatial_shape: Sequence[int]) -> tuple[tuple[int, int], ...]:
new_size = compute_divisible_spatial_size(spatial_shape=spatial_shape, k=self.k)
spatial_pad = SpatialPad(spatial_size=new_size, method=self.method)
return spatial_pad.compute_pad_width(spatial_shape)
Expand Down
3 changes: 2 additions & 1 deletion monai/transforms/croppad/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from __future__ import annotations

import warnings
from collections.abc import Sequence

import numpy as np
import torch
Expand Down Expand Up @@ -154,7 +155,7 @@ def crop_or_pad_nd(img: torch.Tensor, translation_mat, spatial_size: tuple[int,

def pad_func(
img: torch.Tensor,
to_pad: tuple[tuple[int, int]],
to_pad: Sequence[tuple[int, int]],
transform_info: dict,
mode: str = PytorchPadMode.CONSTANT,
lazy: bool = False,
Expand Down
Loading