Skip to content

Commit

Permalink
Merge branch 'dev' into nnunetv2
Browse files Browse the repository at this point in the history
  • Loading branch information
KumoLiu authored Feb 21, 2024
2 parents ff35c37 + 1b93988 commit b378a37
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion monai/utils/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def load_submodules(
if (is_pkg or load_all) and name not in sys.modules and match(exclude_pattern, name) is None:
try:
mod = import_module(name)
importer.find_module(name).load_module(name) # type: ignore
importer.find_spec(name).loader.load_module(name) # type: ignore
submodules.append(mod)
except OptionalImportError:
pass # could not import the optional deps., they are ignored
Expand Down
11 changes: 9 additions & 2 deletions tests/test_resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@
from monai.data import MetaTensor, set_track_meta
from monai.transforms import Resize
from tests.lazy_transforms_utils import test_resampler_lazy
from tests.utils import TEST_NDARRAYS_ALL, NumpyImageTestCase2D, assert_allclose, is_tf32_env, pytorch_after
from tests.utils import (
TEST_NDARRAYS_ALL,
NumpyImageTestCase2D,
SkipIfAtLeastPyTorchVersion,
assert_allclose,
is_tf32_env,
pytorch_after,
)

TEST_CASE_0 = [{"spatial_size": 15}, (6, 10, 15)]

Expand All @@ -39,7 +46,6 @@


class TestResize(NumpyImageTestCase2D):

def test_invalid_inputs(self):
with self.assertRaises(ValueError):
resize = Resize(spatial_size=(128, 128, 3), mode="order")
Expand Down Expand Up @@ -112,6 +118,7 @@ def test_correct_results(self, spatial_size, mode, anti_aliasing):
)

@parameterized.expand([TEST_CASE_0, TEST_CASE_1, TEST_CASE_2, TEST_CASE_2_1, TEST_CASE_3, TEST_CASE_4])
@SkipIfAtLeastPyTorchVersion((2, 2, 0)) # https://github.com/Project-MONAI/MONAI/issues/7445
def test_longest_shape(self, input_param, expected_shape):
input_data = np.random.randint(0, 2, size=[3, 4, 7, 10])
input_param["size_mode"] = "longest"
Expand Down
10 changes: 8 additions & 2 deletions tests/test_resized.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@
from monai.data import MetaTensor, set_track_meta
from monai.transforms import Invertd, Resize, Resized
from tests.lazy_transforms_utils import test_resampler_lazy
from tests.utils import TEST_NDARRAYS_ALL, NumpyImageTestCase2D, assert_allclose, test_local_inversion
from tests.utils import (
TEST_NDARRAYS_ALL,
NumpyImageTestCase2D,
SkipIfAtLeastPyTorchVersion,
assert_allclose,
test_local_inversion,
)

TEST_CASE_0 = [{"keys": "img", "spatial_size": 15}, (6, 10, 15)]

Expand Down Expand Up @@ -58,8 +64,8 @@
]


@SkipIfAtLeastPyTorchVersion((2, 2, 0)) # https://github.com/Project-MONAI/MONAI/issues/7445
class TestResized(NumpyImageTestCase2D):

def test_invalid_inputs(self):
with self.assertRaises(ValueError):
resize = Resized(keys="img", spatial_size=(128, 128, 3), mode="order")
Expand Down

0 comments on commit b378a37

Please sign in to comment.