Skip to content

Commit

Permalink
Fix Premerge (#7397)
Browse files Browse the repository at this point in the history
Fixes #7396


### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
  • Loading branch information
KumoLiu authored Jan 18, 2024
1 parent 25f1901 commit 78295c7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ max_line_length = 120
# B028 https://github.com/Project-MONAI/MONAI/issues/5855
# B907 https://github.com/Project-MONAI/MONAI/issues/5868
# B908 https://github.com/Project-MONAI/MONAI/issues/6503
# B036 https://github.com/Project-MONAI/MONAI/issues/7396
ignore =
E203
E501
Expand All @@ -186,6 +187,7 @@ ignore =
B028
B907
B908
B036
per_file_ignores = __init__.py: F401, __main__.py: F401
exclude = *.pyi,.git,.eggs,monai/_version.py,versioneer.py,venv,.venv,_version.py

Expand Down
2 changes: 1 addition & 1 deletion tests/test_flexible_unet.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DummyEncoder(BaseEncoder):
def get_encoder_parameters(cls):
basic_dict = {"spatial_dims": 2, "in_channels": 3, "pretrained": False}
param_dict_list = [basic_dict]
for key in basic_dict:
for key in basic_dict.keys():
cur_dict = basic_dict.copy()
del cur_dict[key]
param_dict_list.append(cur_dict)
Expand Down
12 changes: 6 additions & 6 deletions tests/test_invertd.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ def test_invert(self):
self.assertTupleEqual(i.shape[1:], (101, 100, 107))

# check the case that different items use different interpolation mode to invert transforms
d = item["image_inverted1"]
j = item["image_inverted1"]
# if the interpolation mode is nearest, accumulated diff should be smaller than 1
self.assertLess(torch.sum(d.to(torch.float) - d.to(torch.uint8).to(torch.float)).item(), 1.0)
self.assertTupleEqual(d.shape, (1, 101, 100, 107))
self.assertLess(torch.sum(j.to(torch.float) - j.to(torch.uint8).to(torch.float)).item(), 1.0)
self.assertTupleEqual(j.shape, (1, 101, 100, 107))

d = item["label_inverted1"]
k = item["label_inverted1"]
# if the interpolation mode is not nearest, accumulated diff should be greater than 10000
self.assertGreater(torch.sum(d.to(torch.float) - d.to(torch.uint8).to(torch.float)).item(), 10000.0)
self.assertTupleEqual(d.shape, (1, 101, 100, 107))
self.assertGreater(torch.sum(k.to(torch.float) - k.to(torch.uint8).to(torch.float)).item(), 10000.0)
self.assertTupleEqual(k.shape, (1, 101, 100, 107))

# check labels match
reverted = item["label_inverted"].detach().cpu().numpy().astype(np.int32)
Expand Down

0 comments on commit 78295c7

Please sign in to comment.