Skip to content

Commit f78c3f9

Browse files
committed
Suppress mypy warnings about incompatible superclass signature
Related to Project-MONAI#495
1 parent b03ade1 commit f78c3f9

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

monai/transforms/croppad/array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def _determine_data_pad_width(self, data_shape):
5353
else:
5454
return [(0, max(self.spatial_size[i] - data_shape[i], 0)) for i in range(len(self.spatial_size))]
5555

56-
def __call__(self, img, mode: Optional[str] = None):
56+
def __call__(self, img, mode: Optional[str] = None): # type: ignore # see issue #495
5757
data_pad_width = self._determine_data_pad_width(img.shape[1:])
5858
all_pad_width = [(0, 0)] + data_pad_width
5959
img = np.pad(img, all_pad_width, mode=mode or self.mode)

monai/transforms/post/array.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, to_onehot: bool = False, num_classes: Optional[int] = None):
3838
self.to_onehot = to_onehot
3939
self.num_classes = num_classes
4040

41-
def __call__(self, img, to_onehot: Optional[bool] = None, num_classes: Optional[int] = None):
41+
def __call__(self, img, to_onehot: Optional[bool] = None, num_classes: Optional[int] = None): # type: ignore # see issue #495
4242
if to_onehot or self.to_onehot:
4343
if num_classes is None:
4444
num_classes = self.num_classes
@@ -69,7 +69,7 @@ def __init__(self, sigmoid: bool = False, softmax: bool = False, other: Optional
6969
self.softmax = softmax
7070
self.other = other
7171

72-
def __call__(
72+
def __call__( # type: ignore # see issue #495
7373
self, img, sigmoid: Optional[bool] = None, softmax: Optional[bool] = None, other: Optional[Callable] = None
7474
):
7575
if sigmoid is True and softmax is True:
@@ -118,7 +118,7 @@ def __init__(
118118
self.threshold_values = threshold_values
119119
self.logit_thresh = logit_thresh
120120

121-
def __call__(
121+
def __call__( # type: ignore # see issue #495
122122
self,
123123
img,
124124
argmax: Optional[bool] = None,

monai/transforms/spatial/array.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def __init__(
7979
self.cval = cval
8080
self.dtype = dtype
8181

82-
def __call__(
82+
def __call__( # type: ignore # see issue #495
8383
self,
8484
data_array: np.ndarray,
8585
affine=None,
@@ -162,7 +162,7 @@ def __init__(self, axcodes=None, as_closest_canonical: bool = False, labels=tupl
162162
self.as_closest_canonical = as_closest_canonical
163163
self.labels = labels
164164

165-
def __call__(self, data_array: np.ndarray, affine=None):
165+
def __call__(self, data_array: np.ndarray, affine=None): # type: ignore # see issue #495
166166
"""
167167
original orientation of `data_array` is defined by `affine`.
168168
@@ -261,7 +261,7 @@ def __init__(
261261
self.preserve_range = preserve_range
262262
self.anti_aliasing = anti_aliasing
263263

264-
def __call__(
264+
def __call__( # type: ignore # see issue #495
265265
self,
266266
img,
267267
order=None,
@@ -329,7 +329,7 @@ def __init__(
329329
self.cval = cval
330330
self.prefilter = prefilter
331331

332-
def __call__(
332+
def __call__( # type: ignore # see issue #495
333333
self,
334334
img,
335335
order=None,
@@ -471,7 +471,7 @@ def __init__(self, k: int = 1, spatial_axes=(0, 1)):
471471
self.k = k
472472
self.spatial_axes = spatial_axes
473473

474-
def __call__(self, img: np.ndarray):
474+
def __call__(self, img: np.ndarray): # type: ignore # see issue #495
475475
"""
476476
Args:
477477
img (ndarray): channel first array, must have shape: (num_channels, H[, W, ..., ]),
@@ -567,7 +567,7 @@ def randomize(self):
567567
self._do_transform = self.R.random_sample() < self.prob
568568
self.angle = self.R.uniform(low=self.degrees[0], high=self.degrees[1])
569569

570-
def __call__(
570+
def __call__( # type: ignore # see issue #495
571571
self,
572572
img,
573573
order=None,
@@ -671,7 +671,7 @@ def randomize(self):
671671
else:
672672
self._zoom = self.R.uniform(self.min_zoom, self.max_zoom)
673673

674-
def __call__(
674+
def __call__( # type: ignore # see issue #495
675675
self,
676676
img,
677677
order=None,
@@ -887,7 +887,7 @@ def __init__(
887887
self.as_tensor_output = as_tensor_output
888888
self.device = device
889889

890-
def __call__(
890+
def __call__( # type: ignore # see issue #495
891891
self,
892892
img: Union[np.ndarray, torch.Tensor],
893893
grid: Union[np.ndarray, torch.Tensor],
@@ -977,7 +977,7 @@ def __init__(
977977
self.padding_mode = padding_mode
978978
self.mode = mode
979979

980-
def __call__(
980+
def __call__( # type: ignore # see issue #495
981981
self,
982982
img: Union[np.ndarray, torch.Tensor],
983983
spatial_size=None,
@@ -1061,7 +1061,7 @@ def randomize(self):
10611061
self.do_transform = self.R.rand() < self.prob
10621062
self.rand_affine_grid.randomize()
10631063

1064-
def __call__(
1064+
def __call__( # type: ignore # see issue #495
10651065
self,
10661066
img: Union[np.ndarray, torch.Tensor],
10671067
spatial_size=None,
@@ -1158,7 +1158,7 @@ def randomize(self, spatial_size):
11581158
self.deform_grid.randomize(spatial_size)
11591159
self.rand_affine_grid.randomize()
11601160

1161-
def __call__(
1161+
def __call__( # type: ignore # see issue #495
11621162
self,
11631163
img: Union[np.ndarray, torch.Tensor],
11641164
spatial_size=None,

monai/transforms/utility/array.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def __init__(self, dtype: np.dtype = np.float32):
118118
"""
119119
self.dtype = dtype
120120

121-
def __call__(self, img: np.ndarray):
121+
def __call__(self, img: np.ndarray): # type: ignore # see issue #495
122122
assert isinstance(img, np.ndarray), "image must be numpy array."
123123
return img.astype(self.dtype)
124124

@@ -161,7 +161,7 @@ def __init__(self, dim: Optional[int] = None):
161161
assert isinstance(dim, int) and dim >= -1, "invalid channel dimension."
162162
self.dim = dim
163163

164-
def __call__(self, img: np.ndarray):
164+
def __call__(self, img: np.ndarray): # type: ignore # see issue #495
165165
"""
166166
Args:
167167
img (ndarray): numpy arrays with required dimension `dim` removed
@@ -209,7 +209,7 @@ def __init__(
209209
if logger_handler is not None:
210210
self._logger.addHandler(logger_handler)
211211

212-
def __call__(
212+
def __call__( # type: ignore # see issue #495
213213
self,
214214
img,
215215
prefix: Optional[str] = None,

0 commit comments

Comments
 (0)