Skip to content

Commit 718e4be

Browse files
authored
auto updates (#7439)
Signed-off-by: monai-bot <[email protected]> Signed-off-by: monai-bot <[email protected]>
1 parent 33afaef commit 718e4be

File tree

734 files changed

+1046
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

734 files changed

+1046
-4
lines changed

monai/apps/datasets.py

+1
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ def get_dataset(self, folds: Sequence[int] | int, **dataset_params: Any) -> obje
737737
dataset_params_.update(dataset_params)
738738

739739
class _NsplitsDataset(self.dataset_cls): # type: ignore
740+
740741
def _split_datalist(self, datalist: list[dict]) -> list[dict]:
741742
data = partition_dataset(data=datalist, num_partitions=nfolds, shuffle=True, seed=seed)
742743
return select_cross_validation_folds(partitions=data, folds=folds)

monai/apps/deepedit/transforms.py

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535

3636
class DiscardAddGuidanced(MapTransform):
37+
3738
def __init__(
3839
self,
3940
keys: KeysCollection,
@@ -84,6 +85,7 @@ def __call__(self, data: Mapping[Hashable, np.ndarray]) -> dict[Hashable, np.nda
8485

8586

8687
class NormalizeLabelsInDatasetd(MapTransform):
88+
8789
def __init__(
8890
self, keys: KeysCollection, label_names: dict[str, int] | None = None, allow_missing_keys: bool = False
8991
):
@@ -121,6 +123,7 @@ def __call__(self, data: Mapping[Hashable, np.ndarray]) -> dict[Hashable, np.nda
121123

122124

123125
class SingleLabelSelectiond(MapTransform):
126+
124127
def __init__(
125128
self, keys: KeysCollection, label_names: Sequence[str] | None = None, allow_missing_keys: bool = False
126129
):

monai/apps/detection/metrics/coco.py

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272

7373

7474
class COCOMetric:
75+
7576
def __init__(
7677
self,
7778
classes: Sequence[str],

monai/apps/detection/utils/ATSS_matcher.py

+1
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def compute_matches(
164164

165165

166166
class ATSSMatcher(Matcher):
167+
167168
def __init__(
168169
self,
169170
num_candidates: int = 4,

monai/apps/pathology/transforms/post/array.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def __call__(self, prob_map: NdarrayOrTensor) -> NdarrayOrTensor:
162162
pred = label(pred)[0]
163163
if self.remove_small_objects is not None:
164164
pred = self.remove_small_objects(pred)
165-
pred[pred > 0] = 1 # type: ignore
165+
pred[pred > 0] = 1
166166

167167
return convert_to_dst_type(pred, prob_map, dtype=self.dtype)[0]
168168

@@ -338,7 +338,7 @@ def __call__(self, mask: NdarrayOrTensor, instance_border: NdarrayOrTensor) -> N
338338
instance_border = instance_border >= self.threshold # uncertain area
339339

340340
marker = mask - convert_to_dst_type(instance_border, mask)[0] # certain foreground
341-
marker[marker < 0] = 0 # type: ignore
341+
marker[marker < 0] = 0
342342
marker = self.postprocess_fn(marker)
343343
marker = convert_to_numpy(marker)
344344

@@ -634,7 +634,7 @@ def __call__( # type: ignore
634634

635635
seg_map_crop = convert_to_dst_type(seg_map_crop == instance_id, type_map_crop, dtype=bool)[0]
636636

637-
inst_type = type_map_crop[seg_map_crop] # type: ignore
637+
inst_type = type_map_crop[seg_map_crop]
638638
type_list, type_pixels = unique(inst_type, return_counts=True)
639639
type_list = list(zip(type_list, type_pixels))
640640
type_list = sorted(type_list, key=lambda x: x[1], reverse=True)

monai/data/dataset.py

+1
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,7 @@ def __len__(self) -> int:
12751275
return min(len(dataset) for dataset in self.data)
12761276

12771277
def _transform(self, index: int):
1278+
12781279
def to_list(x):
12791280
return list(x) if isinstance(x, (tuple, list)) else [x]
12801281

monai/fl/client/client_algo.py

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def abort(self, extra: dict | None = None) -> None:
5757

5858

5959
class ClientAlgoStats(BaseClient):
60+
6061
def get_data_stats(self, extra: dict | None = None) -> ExchangeObject:
6162
"""
6263
Get summary statistics about the local data.

monai/handlers/ignite_metric.py

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def attach(self, engine: Engine, name: str) -> None: # type: ignore[override]
157157

158158
@deprecated(since="1.2", removed="1.4", msg_suffix="Use IgniteMetricHandler instead of IgniteMetric.")
159159
class IgniteMetric(IgniteMetricHandler):
160+
160161
def __init__(
161162
self,
162163
metric_fn: CumulativeIterationMetric | None = None,

monai/metrics/f_beta_score.py

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323

2424
class FBetaScore(CumulativeIterationMetric):
25+
2526
def __init__(
2627
self,
2728
beta: float = 1.0,

monai/networks/blocks/dynunet_block.py

+1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ def forward(self, inp, skip):
245245

246246

247247
class UnetOutBlock(nn.Module):
248+
248249
def __init__(
249250
self, spatial_dims: int, in_channels: int, out_channels: int, dropout: tuple | str | float | None = None
250251
):

monai/networks/blocks/localnet_block.py

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def get_deconv_block(spatial_dims: int, in_channels: int, out_channels: int) ->
7272

7373

7474
class ResidualBlock(nn.Module):
75+
7576
def __init__(
7677
self, spatial_dims: int, in_channels: int, out_channels: int, kernel_size: Sequence[int] | int
7778
) -> None:
@@ -95,6 +96,7 @@ def forward(self, x) -> torch.Tensor:
9596

9697

9798
class LocalNetResidualBlock(nn.Module):
99+
98100
def __init__(self, spatial_dims: int, in_channels: int, out_channels: int) -> None:
99101
super().__init__()
100102
if in_channels != out_channels:

monai/networks/blocks/pos_embed_utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
# From PyTorch internals
2525
def _ntuple(n):
26+
2627
def parse(x):
2728
if isinstance(x, collections.abc.Iterable) and not isinstance(x, str):
2829
return tuple(x)

monai/networks/layers/gmm.py

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def apply(self, features):
7878

7979

8080
class _ApplyFunc(torch.autograd.Function):
81+
8182
@staticmethod
8283
def forward(ctx, params, features, compiled_extension):
8384
return compiled_extension.apply(params, features)

monai/networks/layers/simplelayers.py

+2
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ def forward(self, in_tensor: torch.Tensor, number_of_passes=1) -> torch.Tensor:
552552

553553

554554
class GaussianFilter(nn.Module):
555+
555556
def __init__(
556557
self,
557558
spatial_dims: int,
@@ -607,6 +608,7 @@ def forward(self, x: torch.Tensor) -> torch.Tensor:
607608

608609

609610
class LLTMFunction(Function):
611+
610612
@staticmethod
611613
def forward(ctx, input, weights, bias, old_h, old_cell):
612614
outputs = _C.lltm_forward(input, weights, bias, old_h, old_cell)

monai/networks/layers/spatial_transforms.py

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434

3535
class _GridPull(torch.autograd.Function):
36+
3637
@staticmethod
3738
def forward(ctx, input, grid, interpolation, bound, extrapolate):
3839
opt = (bound, interpolation, extrapolate)
@@ -132,6 +133,7 @@ def grid_pull(
132133

133134

134135
class _GridPush(torch.autograd.Function):
136+
135137
@staticmethod
136138
def forward(ctx, input, grid, shape, interpolation, bound, extrapolate):
137139
opt = (bound, interpolation, extrapolate)
@@ -236,6 +238,7 @@ def grid_push(
236238

237239

238240
class _GridCount(torch.autograd.Function):
241+
239242
@staticmethod
240243
def forward(ctx, grid, shape, interpolation, bound, extrapolate):
241244
opt = (bound, interpolation, extrapolate)
@@ -335,6 +338,7 @@ def grid_count(grid: torch.Tensor, shape=None, interpolation="linear", bound="ze
335338

336339

337340
class _GridGrad(torch.autograd.Function):
341+
338342
@staticmethod
339343
def forward(ctx, input, grid, interpolation, bound, extrapolate):
340344
opt = (bound, interpolation, extrapolate)
@@ -433,6 +437,7 @@ def grid_grad(input: torch.Tensor, grid: torch.Tensor, interpolation="linear", b
433437

434438

435439
class AffineTransform(nn.Module):
440+
436441
def __init__(
437442
self,
438443
spatial_size: Sequence[int] | int | None = None,

monai/networks/nets/ahnet.py

+6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def forward(self, x):
8787

8888

8989
class Projection(nn.Sequential):
90+
9091
def __init__(self, spatial_dims: int, num_input_features: int, num_output_features: int):
9192
super().__init__()
9293

@@ -100,6 +101,7 @@ def __init__(self, spatial_dims: int, num_input_features: int, num_output_featur
100101

101102

102103
class DenseBlock(nn.Sequential):
104+
103105
def __init__(
104106
self,
105107
spatial_dims: int,
@@ -118,6 +120,7 @@ def __init__(
118120

119121

120122
class UpTransition(nn.Sequential):
123+
121124
def __init__(
122125
self, spatial_dims: int, num_input_features: int, num_output_features: int, upsample_mode: str = "transpose"
123126
):
@@ -143,6 +146,7 @@ def __init__(
143146

144147

145148
class Final(nn.Sequential):
149+
146150
def __init__(
147151
self, spatial_dims: int, num_input_features: int, num_output_features: int, upsample_mode: str = "transpose"
148152
):
@@ -178,6 +182,7 @@ def __init__(
178182

179183

180184
class Pseudo3DLayer(nn.Module):
185+
181186
def __init__(self, spatial_dims: int, num_input_features: int, growth_rate: int, bn_size: int, dropout_prob: float):
182187
super().__init__()
183188
# 1x1x1
@@ -244,6 +249,7 @@ def forward(self, x):
244249

245250

246251
class PSP(nn.Module):
252+
247253
def __init__(self, spatial_dims: int, psp_block_num: int, in_ch: int, upsample_mode: str = "transpose"):
248254
super().__init__()
249255
self.up_modules = nn.ModuleList()

monai/networks/nets/attentionunet.py

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424

2525
class ConvBlock(nn.Module):
26+
2627
def __init__(
2728
self,
2829
spatial_dims: int,
@@ -67,6 +68,7 @@ def forward(self, x: torch.Tensor) -> torch.Tensor:
6768

6869

6970
class UpConv(nn.Module):
71+
7072
def __init__(self, spatial_dims: int, in_channels: int, out_channels: int, kernel_size=3, strides=2, dropout=0.0):
7173
super().__init__()
7274
self.up = Convolution(
@@ -88,6 +90,7 @@ def forward(self, x: torch.Tensor) -> torch.Tensor:
8890

8991

9092
class AttentionBlock(nn.Module):
93+
9194
def __init__(self, spatial_dims: int, f_int: int, f_g: int, f_l: int, dropout=0.0):
9295
super().__init__()
9396
self.W_g = nn.Sequential(
@@ -145,6 +148,7 @@ def forward(self, g: torch.Tensor, x: torch.Tensor) -> torch.Tensor:
145148

146149

147150
class AttentionLayer(nn.Module):
151+
148152
def __init__(
149153
self,
150154
spatial_dims: int,

monai/networks/nets/basic_unet.py

+1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ def forward(self, x: torch.Tensor, x_e: Optional[torch.Tensor]):
176176

177177

178178
class BasicUNet(nn.Module):
179+
179180
def __init__(
180181
self,
181182
spatial_dims: int = 3,

monai/networks/nets/basic_unetplusplus.py

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525

2626
class BasicUNetPlusPlus(nn.Module):
27+
2728
def __init__(
2829
self,
2930
spatial_dims: int = 3,

monai/networks/nets/densenet.py

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343

4444
class _DenseLayer(nn.Module):
45+
4546
def __init__(
4647
self,
4748
spatial_dims: int,
@@ -88,6 +89,7 @@ def forward(self, x: torch.Tensor) -> torch.Tensor:
8889

8990

9091
class _DenseBlock(nn.Sequential):
92+
9193
def __init__(
9294
self,
9395
spatial_dims: int,
@@ -119,6 +121,7 @@ def __init__(
119121

120122

121123
class _Transition(nn.Sequential):
124+
122125
def __init__(
123126
self,
124127
spatial_dims: int,

monai/networks/nets/dints.py

+4
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def _dfs(node, paths):
7373

7474

7575
class _IdentityWithRAMCost(nn.Identity):
76+
7677
def __init__(self, *args, **kwargs):
7778
super().__init__(*args, **kwargs)
7879
self.ram_cost = 0
@@ -105,6 +106,7 @@ def __init__(
105106

106107

107108
class _P3DActiConvNormBlockWithRAMCost(P3DActiConvNormBlock):
109+
108110
def __init__(
109111
self,
110112
in_channel: int,
@@ -122,6 +124,7 @@ def __init__(
122124

123125

124126
class _FactorizedIncreaseBlockWithRAMCost(FactorizedIncreaseBlock):
127+
125128
def __init__(
126129
self,
127130
in_channel: int,
@@ -138,6 +141,7 @@ def __init__(
138141

139142

140143
class _FactorizedReduceBlockWithRAMCost(FactorizedReduceBlock):
144+
141145
def __init__(
142146
self,
143147
in_channel: int,

monai/networks/nets/efficientnet.py

+4
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373

7474

7575
class MBConvBlock(nn.Module):
76+
7677
def __init__(
7778
self,
7879
spatial_dims: int,
@@ -227,6 +228,7 @@ def set_swish(self, memory_efficient: bool = True) -> None:
227228

228229

229230
class EfficientNet(nn.Module):
231+
230232
def __init__(
231233
self,
232234
blocks_args_str: list[str],
@@ -472,6 +474,7 @@ def _initialize_weights(self) -> None:
472474

473475

474476
class EfficientNetBN(EfficientNet):
477+
475478
def __init__(
476479
self,
477480
model_name: str,
@@ -558,6 +561,7 @@ def __init__(
558561

559562

560563
class EfficientNetBNFeatures(EfficientNet):
564+
561565
def __init__(
562566
self,
563567
model_name: str,

monai/networks/nets/highresnet.py

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737

3838
class HighResBlock(nn.Module):
39+
3940
def __init__(
4041
self,
4142
spatial_dims: int,

0 commit comments

Comments
 (0)