Skip to content

Commit 0c2fbac

Browse files
authored
auto updates (#5590)
closes #5588 closes #5589 Signed-off-by: monai-bot <monai.miccai2019@gmail.com> Signed-off-by: monai-bot <monai.miccai2019@gmail.com>
1 parent 2530959 commit 0c2fbac

File tree

9 files changed

+12
-15
lines changed

9 files changed

+12
-15
lines changed

monai/bundle/config_item.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ def _find_module_names(self) -> List[str]:
6464
Find all the modules start with MOD_START and don't contain any of `excludes`.
6565
6666
"""
67-
return [
68-
m for m in sys.modules.keys() if m.startswith(self.MOD_START) and all(s not in m for s in self.excludes)
69-
]
67+
return [m for m in sys.modules if m.startswith(self.MOD_START) and all(s not in m for s in self.excludes)]
7068

7169
def _find_classes_or_functions(self, modnames: Union[Sequence[str], str]) -> Dict[str, List]:
7270
"""

monai/bundle/scripts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ def get_all_bundles_list(
384384

385385
bundles_info = _get_all_bundles_info(repo=repo, tag=tag, auth_token=auth_token)
386386
bundles_list = []
387-
for bundle_name in bundles_info.keys():
387+
for bundle_name in bundles_info:
388388
latest_version = sorted(bundles_info[bundle_name].keys())[-1]
389389
bundles_list.append((bundle_name, latest_version))
390390

monai/losses/multi_scale.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def __init__(
6060
kernel: gaussian or cauchy.
6161
"""
6262
super().__init__(reduction=LossReduction(reduction).value)
63-
if kernel not in kernel_fn_dict.keys():
63+
if kernel not in kernel_fn_dict:
6464
raise ValueError(f"got unsupported kernel type: {kernel}", "only support gaussian and cauchy")
6565
self.kernel_fn = kernel_fn_dict[kernel]
6666
self.loss = loss

monai/networks/nets/efficientnet.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ def __init__(
529529
]
530530

531531
# check if model_name is valid model
532-
if model_name not in efficientnet_params.keys():
532+
if model_name not in efficientnet_params:
533533
model_name_string = ", ".join(efficientnet_params.keys())
534534
raise ValueError(f"invalid model_name {model_name} found, must be one of {model_name_string} ")
535535

@@ -586,7 +586,7 @@ def __init__(
586586
]
587587

588588
# check if model_name is valid model
589-
if model_name not in efficientnet_params.keys():
589+
if model_name not in efficientnet_params:
590590
model_name_string = ", ".join(efficientnet_params.keys())
591591
raise ValueError(f"invalid model_name {model_name} found, must be one of {model_name_string} ")
592592

@@ -720,7 +720,7 @@ def get_efficientnet_image_size(model_name: str) -> int:
720720
721721
"""
722722
# check if model_name is valid model
723-
if model_name not in efficientnet_params.keys():
723+
if model_name not in efficientnet_params:
724724
model_name_string = ", ".join(efficientnet_params.keys())
725725
raise ValueError(f"invalid model_name {model_name} found, must be one of {model_name_string} ")
726726

monai/transforms/compose.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def flatten(self):
158158
"""
159159
new_transforms = []
160160
for t in self.transforms:
161-
if type(t) is Compose:
161+
if type(t) is Compose: # nopep8
162162
new_transforms += t.flatten().transforms
163163
else:
164164
new_transforms.append(t)

monai/transforms/signal/array.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def __call__(self, signal: NdarrayOrTensor) -> NdarrayOrTensor:
140140
self.randomize(None)
141141
self.magnitude = self.R.uniform(low=self.boundaries[0], high=self.boundaries[1])
142142

143-
length = signal.shape[len(signal.shape) - 1]
143+
length = signal.shape[-1]
144144
mask = torch.zeros(round(self.magnitude * length))
145145
trange = torch.arange(length)
146146
loc = trange[torch.randint(0, trange.size(0), (1,))]
@@ -265,7 +265,7 @@ def __call__(self, signal: NdarrayOrTensor) -> NdarrayOrTensor:
265265
self.fracs = self.R.uniform(low=self.fraction[0], high=self.fraction[1])
266266
self.freqs = self.R.uniform(low=self.frequencies[0], high=self.frequencies[1])
267267

268-
length = signal.shape[len(signal.shape) - 1]
268+
length = signal.shape[-1]
269269

270270
time_partial = np.arange(0, round(self.fracs * length), 1)
271271
data = convert_to_tensor(self.freqs * time_partial)
@@ -347,7 +347,7 @@ def __call__(self, signal: NdarrayOrTensor) -> NdarrayOrTensor:
347347
self.fracs = self.R.uniform(low=self.fraction[0], high=self.fraction[1])
348348
self.freqs = self.R.uniform(low=self.frequencies[0], high=self.frequencies[1])
349349

350-
length = signal.shape[len(signal.shape) - 1]
350+
length = signal.shape[-1]
351351

352352
time_partial = np.arange(0, round(self.fracs * length), 1)
353353
squaredpulse_partial = self.magnitude * squarepulse(self.freqs * time_partial)

monai/transforms/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1746,7 +1746,7 @@ def paste_slices(tup):
17461746
given a tuple (pos,w,max_w), return a tuple of slices
17471747
"""
17481748
pos, w, max_w = tup
1749-
max_w = max_w.shape[len(max_w.shape) - 1]
1749+
max_w = max_w.shape[-1]
17501750
orig_min = max(pos, 0)
17511751
orig_max = min(pos + w, max_w)
17521752
block_min = -min(pos, 0)

tests/test_flatten_sub_keysd.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
D1 = {"a": A, "b": B}
2424
D2 = {"a": A, "b": B, "c": C}
2525

26-
2726
TEST_CASE_0 = [{"keys": "pred"}, {"image": I, "pred": D1}, {"a": A, "b": B, "image": I}]
2827
TEST_CASE_1 = [{"keys": "pred"}, {"image": I, "pred": D2}, {"a": A, "b": B, "c": C, "image": I}]
2928
TEST_CASE_2 = [{"keys": "pred", "sub_keys": ["a", "b"]}, {"image": I, "pred": D1}, {"a": A, "b": B, "image": I}]

tests/test_global_mutual_information_loss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def transformation(translate_params=(0.0, 0.0, 0.0), rotate_params=(0.0, 0.0, 0.
9494
a1 = transformation()
9595
a1 = torch.tensor(a1).unsqueeze(0).unsqueeze(0).to(device)
9696

97-
for mode in transform_params_dict.keys():
97+
for mode in transform_params_dict:
9898
transform_params_list = transform_params_dict[mode]
9999
expected_value_list = EXPECTED_VALUE[mode]
100100
for transform_params, expected_value in zip(transform_params_list, expected_value_list):

0 commit comments

Comments
 (0)