Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions monai/bundle/config_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ def _find_module_names(self) -> List[str]:
Find all the modules start with MOD_START and don't contain any of `excludes`.

"""
return [
m for m in sys.modules.keys() if m.startswith(self.MOD_START) and all(s not in m for s in self.excludes)
]
return [m for m in sys.modules if m.startswith(self.MOD_START) and all(s not in m for s in self.excludes)]

def _find_classes_or_functions(self, modnames: Union[Sequence[str], str]) -> Dict[str, List]:
"""
Expand Down
2 changes: 1 addition & 1 deletion monai/bundle/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def get_all_bundles_list(

bundles_info = _get_all_bundles_info(repo=repo, tag=tag, auth_token=auth_token)
bundles_list = []
for bundle_name in bundles_info.keys():
for bundle_name in bundles_info:
latest_version = sorted(bundles_info[bundle_name].keys())[-1]
bundles_list.append((bundle_name, latest_version))

Expand Down
2 changes: 1 addition & 1 deletion monai/losses/multi_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(
kernel: gaussian or cauchy.
"""
super().__init__(reduction=LossReduction(reduction).value)
if kernel not in kernel_fn_dict.keys():
if kernel not in kernel_fn_dict:
raise ValueError(f"got unsupported kernel type: {kernel}", "only support gaussian and cauchy")
self.kernel_fn = kernel_fn_dict[kernel]
self.loss = loss
Expand Down
6 changes: 3 additions & 3 deletions monai/networks/nets/efficientnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def __init__(
]

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

Expand Down Expand Up @@ -586,7 +586,7 @@ def __init__(
]

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

Expand Down Expand Up @@ -720,7 +720,7 @@ def get_efficientnet_image_size(model_name: str) -> int:

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

Expand Down
2 changes: 1 addition & 1 deletion monai/transforms/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def flatten(self):
"""
new_transforms = []
for t in self.transforms:
if type(t) is Compose:
if type(t) is Compose: # nopep8
new_transforms += t.flatten().transforms
else:
new_transforms.append(t)
Expand Down
6 changes: 3 additions & 3 deletions monai/transforms/signal/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __call__(self, signal: NdarrayOrTensor) -> NdarrayOrTensor:
self.randomize(None)
self.magnitude = self.R.uniform(low=self.boundaries[0], high=self.boundaries[1])

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

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

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

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

time_partial = np.arange(0, round(self.fracs * length), 1)
squaredpulse_partial = self.magnitude * squarepulse(self.freqs * time_partial)
Expand Down
2 changes: 1 addition & 1 deletion monai/transforms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ def paste_slices(tup):
given a tuple (pos,w,max_w), return a tuple of slices
"""
pos, w, max_w = tup
max_w = max_w.shape[len(max_w.shape) - 1]
max_w = max_w.shape[-1]
orig_min = max(pos, 0)
orig_max = min(pos + w, max_w)
block_min = -min(pos, 0)
Expand Down
1 change: 0 additions & 1 deletion tests/test_flatten_sub_keysd.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
D1 = {"a": A, "b": B}
D2 = {"a": A, "b": B, "c": C}


TEST_CASE_0 = [{"keys": "pred"}, {"image": I, "pred": D1}, {"a": A, "b": B, "image": I}]
TEST_CASE_1 = [{"keys": "pred"}, {"image": I, "pred": D2}, {"a": A, "b": B, "c": C, "image": I}]
TEST_CASE_2 = [{"keys": "pred", "sub_keys": ["a", "b"]}, {"image": I, "pred": D1}, {"a": A, "b": B, "image": I}]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_global_mutual_information_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def transformation(translate_params=(0.0, 0.0, 0.0), rotate_params=(0.0, 0.0, 0.
a1 = transformation()
a1 = torch.tensor(a1).unsqueeze(0).unsqueeze(0).to(device)

for mode in transform_params_dict.keys():
for mode in transform_params_dict:
transform_params_list = transform_params_dict[mode]
expected_value_list = EXPECTED_VALUE[mode]
for transform_params, expected_value in zip(transform_params_list, expected_value_list):
Expand Down