Skip to content

Commit 8b31f24

Browse files
committed
DCO Remediation Commit for sewon.jeon <irocks0922@gmail.com>
I, sewon.jeon <irocks0922@gmail.com>, hereby add my Signed-off-by to this commit: 95222f3 Signed-off-by: sewon.jeon <irocks0922@gmail.com>
1 parent 51d711b commit 8b31f24

File tree

18 files changed

+29
-39
lines changed

18 files changed

+29
-39
lines changed

monai/apps/detection/transforms/box_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def convert_box_to_mask(
267267
boxes_only_mask = np.ones(box_size, dtype=np.int16) * np.int16(labels_np[b])
268268
# apply to global mask
269269
slicing = [b]
270-
slicing.extend(slice(boxes_np[b, d], boxes_np[b, d + spatial_dims]) for d in range(spatial_dims)) # type:ignore
270+
slicing.extend(slice(boxes_np[b, d], boxes_np[b, d + spatial_dims]) for d in range(spatial_dims)) # type: ignore
271271
boxes_mask_np[tuple(slicing)] = boxes_only_mask
272272
return convert_to_dst_type(src=boxes_mask_np, dst=boxes, dtype=torch.int16)[0]
273273

monai/apps/detection/utils/anchor_utils.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,8 @@ def __init__(
124124
aspect_ratios = (aspect_ratios,) * len(self.sizes)
125125

126126
if len(self.sizes) != len(aspect_ratios):
127-
raise ValueError(
128-
"len(sizes) and len(aspect_ratios) should be equal. \
129-
It represents the number of feature maps."
130-
)
127+
raise ValueError("len(sizes) and len(aspect_ratios) should be equal. \
128+
It represents the number of feature maps.")
131129

132130
spatial_dims = len(ensure_tuple(aspect_ratios[0][0])) + 1
133131
spatial_dims = look_up_option(spatial_dims, [2, 3])
@@ -172,16 +170,12 @@ def generate_anchors(
172170
scales_t = torch.as_tensor(scales, dtype=dtype, device=device) # sized (N,)
173171
aspect_ratios_t = torch.as_tensor(aspect_ratios, dtype=dtype, device=device) # sized (M,) or (M,2)
174172
if (self.spatial_dims >= 3) and (len(aspect_ratios_t.shape) != 2):
175-
raise ValueError(
176-
f"In {self.spatial_dims}-D image, aspect_ratios for each level should be \
177-
{len(aspect_ratios_t.shape) - 1}-D. But got aspect_ratios with shape {aspect_ratios_t.shape}."
178-
)
173+
raise ValueError(f"In {self.spatial_dims}-D image, aspect_ratios for each level should be \
174+
{len(aspect_ratios_t.shape) - 1}-D. But got aspect_ratios with shape {aspect_ratios_t.shape}.")
179175

180176
if (self.spatial_dims >= 3) and (aspect_ratios_t.shape[1] != self.spatial_dims - 1):
181-
raise ValueError(
182-
f"In {self.spatial_dims}-D image, aspect_ratios for each level should has \
183-
shape (_,{self.spatial_dims - 1}). But got aspect_ratios with shape {aspect_ratios_t.shape}."
184-
)
177+
raise ValueError(f"In {self.spatial_dims}-D image, aspect_ratios for each level should has \
178+
shape (_,{self.spatial_dims - 1}). But got aspect_ratios with shape {aspect_ratios_t.shape}.")
185179

186180
# if 2d, w:h = 1:aspect_ratios
187181
if self.spatial_dims == 2:

monai/apps/reconstruction/transforms/array.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,8 @@ def __init__(
6161
real/imaginary parts.
6262
"""
6363
if len(center_fractions) != len(accelerations):
64-
raise ValueError(
65-
"Number of center fractions \
66-
should match number of accelerations"
67-
)
64+
raise ValueError("Number of center fractions \
65+
should match number of accelerations")
6866

6967
self.center_fractions = center_fractions
7068
self.accelerations = accelerations

monai/auto3dseg/analyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def update_ops_nested_label(self, nested_key: str, op: Operations) -> None:
105105
raise ValueError("Nested_key input format is wrong. Please ensure it is like key1#0#key2")
106106
root: str
107107
child_key: str
108-
(root, _, child_key) = keys
108+
root, _, child_key = keys
109109
if root not in self.ops:
110110
self.ops[root] = [{}]
111111
self.ops[root][0].update({child_key: None})

monai/bundle/scripts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1948,7 +1948,7 @@ def create_workflow(
19481948
19491949
"""
19501950
_args = update_kwargs(args=args_file, workflow_name=workflow_name, config_file=config_file, **kwargs)
1951-
(workflow_name, config_file) = _pop_args(
1951+
workflow_name, config_file = _pop_args(
19521952
_args, workflow_name=ConfigWorkflow, config_file=None
19531953
) # the default workflow name is "ConfigWorkflow"
19541954
if isinstance(workflow_name, str):

monai/bundle/utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,8 @@
124124
"run_name": None,
125125
# may fill it at runtime
126126
"save_execute_config": True,
127-
"is_not_rank0": (
128-
"$torch.distributed.is_available() \
129-
and torch.distributed.is_initialized() and torch.distributed.get_rank() > 0"
130-
),
127+
"is_not_rank0": ("$torch.distributed.is_available() \
128+
and torch.distributed.is_initialized() and torch.distributed.get_rank() > 0"),
131129
# MLFlowHandler config for the trainer
132130
"trainer": {
133131
"_target_": "MLFlowHandler",

monai/data/dataset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class DatasetFunc(Dataset):
139139
"""
140140

141141
def __init__(self, data: Any, func: Callable, **kwargs) -> None:
142-
super().__init__(data=None, transform=None) # type:ignore
142+
super().__init__(data=None, transform=None) # type: ignore
143143
self.src = data
144144
self.func = func
145145
self.kwargs = kwargs
@@ -1635,7 +1635,7 @@ def _cachecheck(self, item_transformed):
16351635
return (_data, _meta)
16361636
return _data
16371637
else:
1638-
item: list[dict[Any, Any]] = [{} for _ in range(len(item_transformed))] # type:ignore
1638+
item: list[dict[Any, Any]] = [{} for _ in range(len(item_transformed))] # type: ignore
16391639
for i, _item in enumerate(item_transformed):
16401640
for k in _item:
16411641
meta_i_k = self._load_meta_cache(meta_hash_file_name=f"{hashfile.name}-{k}-meta-{i}")

monai/handlers/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def stopping_fn_from_loss() -> Callable[[Engine], Any]:
4848
"""
4949

5050
def stopping_fn(engine: Engine) -> Any:
51-
return -engine.state.output # type:ignore
51+
return -engine.state.output # type: ignore
5252

5353
return stopping_fn
5454

monai/losses/dice.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,9 @@ def forward(self, input: torch.Tensor, target: torch.Tensor) -> torch.Tensor:
204204
self.class_weight = torch.as_tensor([self.class_weight] * num_of_classes)
205205
else:
206206
if self.class_weight.shape[0] != num_of_classes:
207-
raise ValueError(
208-
"""the length of the `weight` sequence should be the same as the number of classes.
207+
raise ValueError("""the length of the `weight` sequence should be the same as the number of classes.
209208
If `include_background=False`, the weight should not include
210-
the background category class 0."""
211-
)
209+
the background category class 0.""")
212210
if self.class_weight.min() < 0:
213211
raise ValueError("the value/values of the `weight` should be no less than 0.")
214212
# apply class_weight to loss

monai/losses/focal_loss.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,9 @@ def forward(self, input: torch.Tensor, target: torch.Tensor) -> torch.Tensor:
183183
self.class_weight = torch.as_tensor([self.class_weight] * num_of_classes)
184184
else:
185185
if self.class_weight.shape[0] != num_of_classes:
186-
raise ValueError(
187-
"""the length of the `weight` sequence should be the same as the number of classes.
186+
raise ValueError("""the length of the `weight` sequence should be the same as the number of classes.
188187
If `include_background=False`, the weight should not include
189-
the background category class 0."""
190-
)
188+
the background category class 0.""")
191189
if self.class_weight.min() < 0:
192190
raise ValueError("the value/values of the `weight` should be no less than 0.")
193191
# apply class_weight to loss

0 commit comments

Comments
 (0)