Skip to content

Commit 16a0614

Browse files
authored
auto updates (#5321)
Signed-off-by: monai-bot <[email protected]> Signed-off-by: monai-bot <[email protected]>
1 parent 32a237a commit 16a0614

18 files changed

+28
-28
lines changed

monai/apps/auto3dseg/bundle_gen.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __init__(self, template_path: str):
7373
# track records when filling template config: {"<config name>": {"<placeholder key>": value, ...}, ...}
7474
self.fill_records: dict = {}
7575

76-
def set_data_stats(self, data_stats_files: str): # type: ignore
76+
def set_data_stats(self, data_stats_files: str):
7777
"""
7878
Set the data analysis report (generated by DataAnalyzer).
7979
@@ -351,7 +351,7 @@ def __init__(self, algo_path: str = ".", algos=None, data_stats_filename=None, d
351351
self.data_src_cfg_filename = data_src_cfg_name
352352
self.history: List[Dict] = []
353353

354-
def set_data_stats(self, data_stats_filename: str): # type: ignore
354+
def set_data_stats(self, data_stats_filename: str):
355355
"""
356356
Set the data stats filename
357357
@@ -377,7 +377,7 @@ def get_data_src(self):
377377
"""Get the data source filename"""
378378
return self.data_src_cfg_filename
379379

380-
def get_history(self) -> List: # type: ignore
380+
def get_history(self) -> List:
381381
"""get the history of the bundleAlgo object with their names/identifiers"""
382382
return self.history
383383

monai/apps/auto3dseg/ensemble_builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def sort_score(self):
176176
scores = concat_val_to_np(self.algos, [AlgoEnsembleKeys.SCORE])
177177
return np.argsort(scores).tolist()
178178

179-
def collect_algos(self, n_best: int = -1): # type: ignore
179+
def collect_algos(self, n_best: int = -1):
180180
"""
181181
Rank the algos by finding the top N (n_best) validation scores.
182182
"""

monai/apps/auto3dseg/hpo_gen.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def get_hyperparameters(self):
154154
warn("NNI is not detected. The code will continue to run without NNI.")
155155
return {}
156156

157-
def update_params(self, params: dict): # type: ignore
157+
def update_params(self, params: dict):
158158
"""
159159
Translate the parameter from monai bundle to meet NNI requirements.
160160
@@ -198,7 +198,7 @@ def set_score(self, acc):
198198
else:
199199
warn("NNI is not detected. The code will continue to run without NNI.")
200200

201-
def run_algo(self, obj_filename: str, output_folder: str = ".", template_path=None) -> None: # type: ignore
201+
def run_algo(self, obj_filename: str, output_folder: str = ".", template_path=None) -> None:
202202
"""
203203
The python interface for NNI to run.
204204
@@ -333,7 +333,7 @@ def __call__(self, trial, obj_filename: str, output_folder: str = ".", template_
333333
self.run_algo(obj_filename, output_folder, template_path)
334334
return self.acc
335335

336-
def update_params(self, params: dict): # type: ignore
336+
def update_params(self, params: dict):
337337
"""
338338
Translate the parameter from monai bundle.
339339
@@ -368,7 +368,7 @@ def generate(self, output_folder: str = ".") -> None:
368368
ConfigParser.export_config_file(self.params, write_path)
369369
logger.info(write_path)
370370

371-
def run_algo(self, obj_filename: str, output_folder: str = ".", template_path=None) -> None: # type: ignore
371+
def run_algo(self, obj_filename: str, output_folder: str = ".", template_path=None) -> None:
372372
"""
373373
The python interface for NNI to run.
374374

monai/auto3dseg/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def concat_val_to_np(
177177
elif ragged:
178178
return np.concatenate(np_list, **kwargs) # type: ignore
179179
else:
180-
return np.concatenate([np_list], **kwargs) # type: ignore
180+
return np.concatenate([np_list], **kwargs)
181181

182182

183183
def concat_multikeys_to_dict(

monai/bundle/config_item.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,15 @@ def resolve_args(self):
257257
"""
258258
return {k: v for k, v in self.get_config().items() if k not in self.non_arg_keys}
259259

260-
def is_disabled(self) -> bool: # type: ignore
260+
def is_disabled(self) -> bool:
261261
"""
262262
Utility function used in `instantiate()` to check whether to skip the instantiation.
263263
264264
"""
265265
_is_disabled = self.get_config().get("_disabled_", False)
266266
return _is_disabled.lower().strip() == "true" if isinstance(_is_disabled, str) else bool(_is_disabled)
267267

268-
def instantiate(self, **kwargs) -> object: # type: ignore
268+
def instantiate(self, **kwargs) -> object:
269269
"""
270270
Instantiate component based on ``self.config`` content.
271271
The target component must be a `class` or a `function`, otherwise, return `None`.

monai/inferers/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ def sliding_window_inference(
276276
final_output = dict(zip(dict_key, output_image_list))
277277
else:
278278
final_output = tuple(output_image_list) # type: ignore
279-
final_output = final_output[0] if is_tensor_output else final_output # type: ignore
279+
final_output = final_output[0] if is_tensor_output else final_output
280+
280281
if isinstance(inputs, MetaTensor):
281282
final_output = convert_to_dst_type(final_output, inputs)[0] # type: ignore
282283
return final_output

monai/metrics/active_learning_metrics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(
4949
self.scalar_reduction = scalar_reduction
5050
self.threshold = threshold
5151

52-
def __call__(self, y_pred: Any) -> Any: # type: ignore
52+
def __call__(self, y_pred: Any) -> Any:
5353
"""
5454
Args:
5555
y_pred: Predicted segmentation, typically segmentation model output.
@@ -88,7 +88,7 @@ def __init__(self, include_background: bool = True, scalar_reduction: str = "sum
8888
self.include_background = include_background
8989
self.scalar_reduction = scalar_reduction
9090

91-
def __call__(self, y_pred: Any, y: Any): # type: ignore
91+
def __call__(self, y_pred: Any, y: Any):
9292
"""
9393
Args:
9494
y_pred: Predicted segmentation, typically segmentation model output.

monai/metrics/confusion_matrix.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,7 @@ def _compute_tensor(self, y_pred: torch.Tensor, y: torch.Tensor): # type: ignor
100100

101101
return get_confusion_matrix(y_pred=y_pred, y=y, include_background=self.include_background)
102102

103-
def aggregate( # type: ignore
104-
self, compute_sample: bool = False, reduction: Union[MetricReduction, str, None] = None
105-
):
103+
def aggregate(self, compute_sample: bool = False, reduction: Union[MetricReduction, str, None] = None):
106104
"""
107105
Execute reduction for the confusion matrix values.
108106

monai/metrics/generalized_dice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def _compute_tensor(self, y_pred: torch.Tensor, y: torch.Tensor): # type: ignor
8080
y_pred=y_pred, y=y, include_background=self.include_background, weight_type=self.weight_type
8181
)
8282

83-
def aggregate(self, reduction: Union[MetricReduction, str, None] = None): # type: ignore
83+
def aggregate(self, reduction: Union[MetricReduction, str, None] = None):
8484
"""
8585
Execute reduction logic for the output of `compute_generalized_dice`.
8686

monai/metrics/hausdorff_distance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def _compute_tensor(self, y_pred: torch.Tensor, y: torch.Tensor): # type: ignor
104104
directed=self.directed,
105105
)
106106

107-
def aggregate(self, reduction: Union[MetricReduction, str, None] = None): # type: ignore
107+
def aggregate(self, reduction: Union[MetricReduction, str, None] = None):
108108
"""
109109
Execute reduction logic for the output of `compute_hausdorff_distance`.
110110

monai/metrics/meandice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _compute_tensor(self, y_pred: torch.Tensor, y: torch.Tensor): # type: ignor
8484
y_pred=y_pred, y=y, include_background=self.include_background, ignore_empty=self.ignore_empty
8585
)
8686

87-
def aggregate(self, reduction: Union[MetricReduction, str, None] = None): # type: ignore
87+
def aggregate(self, reduction: Union[MetricReduction, str, None] = None):
8888
"""
8989
Execute reduction logic for the output of `compute_meandice`.
9090

monai/metrics/meaniou.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _compute_tensor(self, y_pred: torch.Tensor, y: torch.Tensor): # type: ignor
8484
y_pred=y_pred, y=y, include_background=self.include_background, ignore_empty=self.ignore_empty
8585
)
8686

87-
def aggregate(self, reduction: Union[MetricReduction, str, None] = None): # type: ignore
87+
def aggregate(self, reduction: Union[MetricReduction, str, None] = None):
8888
"""
8989
Execute reduction logic for the output of `compute_meaniou`.
9090

monai/metrics/metric.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class IterationMetric(Metric):
4545
Subclasses typically implement the `_compute_tensor` function for the actual tensor computation logic.
4646
"""
4747

48-
def __call__(self, y_pred: TensorOrList, y: Optional[TensorOrList] = None): # type: ignore
48+
def __call__(self, y_pred: TensorOrList, y: Optional[TensorOrList] = None):
4949
"""
5050
Execute basic computation for model prediction `y_pred` and ground truth `y` (optional).
5151
It supports inputs of a list of "channel-first" Tensor and a "batch-first" Tensor.
@@ -310,7 +310,7 @@ class CumulativeIterationMetric(Cumulative, IterationMetric):
310310
311311
"""
312312

313-
def __call__(self, y_pred: TensorOrList, y: Optional[TensorOrList] = None): # type: ignore
313+
def __call__(self, y_pred: TensorOrList, y: Optional[TensorOrList] = None):
314314
"""
315315
Execute basic computation for model prediction and ground truth.
316316
It can support both `list of channel-first Tensor` and `batch-first Tensor`.

monai/metrics/regression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(
4848
self.reduction = reduction
4949
self.get_not_nans = get_not_nans
5050

51-
def aggregate(self, reduction: Union[MetricReduction, str, None] = None): # type: ignore
51+
def aggregate(self, reduction: Union[MetricReduction, str, None] = None):
5252
"""
5353
Args:
5454
reduction: define mode of reduction to the metrics, will only apply reduction on `not-nan` values,

monai/metrics/rocauc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, average: Union[Average, str] = Average.MACRO) -> None:
5151
def _compute_tensor(self, y_pred: torch.Tensor, y: torch.Tensor): # type: ignore
5252
return y_pred, y
5353

54-
def aggregate(self, average: Union[Average, str, None] = None): # type: ignore
54+
def aggregate(self, average: Union[Average, str, None] = None):
5555
"""
5656
Typically `y_pred` and `y` are stored in the cumulative buffers at each iteration,
5757
This function reads the buffers and computes the area under the ROC.

monai/metrics/surface_dice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _compute_tensor(self, y_pred: torch.Tensor, y: torch.Tensor): # type: ignor
8686
distance_metric=self.distance_metric,
8787
)
8888

89-
def aggregate(self, reduction: Union[MetricReduction, str, None] = None): # type: ignore
89+
def aggregate(self, reduction: Union[MetricReduction, str, None] = None):
9090
r"""
9191
Aggregates the output of `_compute_tensor`.
9292

monai/metrics/surface_distance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def _compute_tensor(self, y_pred: torch.Tensor, y: torch.Tensor): # type: ignor
9494
distance_metric=self.distance_metric,
9595
)
9696

97-
def aggregate(self, reduction: Union[MetricReduction, str, None] = None): # type: ignore
97+
def aggregate(self, reduction: Union[MetricReduction, str, None] = None):
9898
"""
9999
Execute reduction logic for the output of `compute_average_surface_distance`.
100100

monai/networks/layers/simplelayers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,8 @@ def median_filter(
497497
else:
498498
kernel = kernel.to(in_tensor)
499499
# map the local window to single vector
500-
conv = [F.conv1d, F.conv2d, F.conv3d][spatial_dims - 1] # type: ignore
500+
conv = [F.conv1d, F.conv2d, F.conv3d][spatial_dims - 1]
501+
501502
if "padding" not in kwargs:
502503
if pytorch_after(1, 10):
503504
kwargs["padding"] = "same"

0 commit comments

Comments
 (0)