Skip to content

Commit

Permalink
Move utils inside utils to avoid coflict
Browse files Browse the repository at this point in the history
  • Loading branch information
garciadias committed Dec 12, 2024
1 parent bb85f53 commit 865dc22
Show file tree
Hide file tree
Showing 529 changed files with 1,395 additions and 528 deletions.
2 changes: 1 addition & 1 deletion tests/apps/detection/networks/test_retinanet.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from monai.networks import eval_mode
from monai.networks.nets import resnet10, resnet18, resnet34, resnet50, resnet101, resnet152, resnet200
from monai.utils import ensure_tuple, optional_import
from tests.utils import SkipIfBeforePyTorchVersion, skip_if_quick, test_onnx_save, test_script_save
from tests.utils.utils import SkipIfBeforePyTorchVersion, skip_if_quick, test_onnx_save, test_script_save

_, has_torchvision = optional_import("torchvision")

Expand Down
2 changes: 1 addition & 1 deletion tests/apps/detection/networks/test_retinanet_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from monai.apps.detection.utils.anchor_utils import AnchorGeneratorWithAnchorShape
from monai.networks import eval_mode, train_mode
from monai.utils import optional_import
from tests.utils import SkipIfBeforePyTorchVersion, skip_if_quick, test_script_save
from tests.utils.utils import SkipIfBeforePyTorchVersion, skip_if_quick, test_script_save

_, has_torchvision = optional_import("torchvision")

Expand Down
2 changes: 1 addition & 1 deletion tests/apps/detection/test_box_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
)
from monai.data.meta_tensor import MetaTensor
from monai.transforms import CastToTyped, Invertd
from tests.utils import TEST_NDARRAYS, assert_allclose
from tests.utils.utils import TEST_NDARRAYS, assert_allclose

TESTS_3D = []
boxes = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 2, 3, 3], [0, 1, 1, 2, 3, 4]]
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/detection/utils/test_anchor_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from monai.apps.detection.utils.anchor_utils import AnchorGenerator, AnchorGeneratorWithAnchorShape
from monai.utils import optional_import
from tests.utils import SkipIfBeforePyTorchVersion, assert_allclose, test_script_save
from tests.utils.utils import SkipIfBeforePyTorchVersion, assert_allclose, test_script_save

_, has_torchvision = optional_import("torchvision")

Expand Down
2 changes: 1 addition & 1 deletion tests/apps/detection/utils/test_atss_box_matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from monai.apps.detection.utils.ATSS_matcher import ATSSMatcher
from monai.data.box_utils import box_iou
from tests.utils import assert_allclose
from tests.utils.utils import assert_allclose

TEST_CASES = [
[
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/detection/utils/test_box_coder.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from monai.apps.detection.utils.box_coder import BoxCoder
from monai.transforms import CastToType
from tests.utils import assert_allclose
from tests.utils.utils import assert_allclose


class TestBoxTransform(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/detection/utils/test_detector_boxselector.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from parameterized import parameterized

from monai.apps.detection.utils.box_selector import BoxSelector
from tests.utils import assert_allclose
from tests.utils.utils import assert_allclose

device = "cuda" if torch.cuda.is_available() else "cpu"
num_anchors = 7
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/detection/utils/test_detector_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from monai.apps.detection.utils.detector_utils import preprocess_images
from monai.utils import ensure_tuple
from tests.utils import assert_allclose
from tests.utils.utils import assert_allclose

TEST_CASE_1 = [ # 3D, batch 3, 2 input channel
{
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/detection/utils/test_hardnegsampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from parameterized import parameterized

from monai.apps.detection.utils.hard_negative_sampler import HardNegativeSampler
from tests.utils import assert_allclose
from tests.utils.utils import assert_allclose

TEST_CASE = [
[[], [], [], [torch.tensor([]), torch.tensor([])], [torch.tensor([]), torch.tensor([])]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from monai.apps.generation.maisi.networks.autoencoderkl_maisi import AutoencoderKlMaisi
from monai.networks import eval_mode
from monai.utils import optional_import
from tests.utils import SkipIfBeforePyTorchVersion
from tests.utils.utils import SkipIfBeforePyTorchVersion

tqdm, has_tqdm = optional_import("tqdm", name="tqdm")
_, has_einops = optional_import("einops")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from monai.apps.generation.maisi.networks.controlnet_maisi import ControlNetMaisi
from monai.networks import eval_mode
from monai.utils import optional_import
from tests.utils import SkipIfBeforePyTorchVersion
from tests.utils.utils import SkipIfBeforePyTorchVersion

_, has_einops = optional_import("einops")

Expand Down
2 changes: 1 addition & 1 deletion tests/apps/pathology/handlers/test_from_engine_hovernet.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from parameterized import parameterized

from monai.apps.pathology.handlers.utils import from_engine_hovernet
from tests.utils import assert_allclose
from tests.utils.utils import assert_allclose

TEST_CASE_0 = [
[{"A": {"C": 1, "D": 2}, "B": {"C": 2, "D": 2}}, {"A": {"C": 3, "D": 2}, "B": {"C": 4, "D": 2}}],
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/pathology/test_prepare_batch_hovernet.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from monai.apps.pathology.engines import PrepareBatchHoVerNet
from monai.engines import SupervisedEvaluator
from monai.utils.enums import HoVerNetBranch
from tests.utils import assert_allclose
from tests.utils.utils import assert_allclose

TEST_CASE_0 = [
{"extra_keys": ["extra_label1", "extra_label2"]},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from monai.apps.pathology.transforms.post.array import GenerateDistanceMap
from monai.transforms.intensity.array import GaussianSmooth
from tests.utils import TEST_NDARRAYS
from tests.utils.utils import TEST_NDARRAYS

EXCEPTION_TESTS = []
TESTS = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from monai.apps.pathology.transforms.post.dictionary import GenerateDistanceMapd
from monai.transforms.intensity.array import GaussianSmooth
from tests.utils import TEST_NDARRAYS
from tests.utils.utils import TEST_NDARRAYS

EXCEPTION_TESTS = []
TESTS = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from parameterized import parameterized

from monai.apps.pathology.transforms.post.array import GenerateInstanceBorder
from tests.utils import TEST_NDARRAYS
from tests.utils.utils import TEST_NDARRAYS

EXCEPTION_TESTS = []
TESTS = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from parameterized import parameterized

from monai.apps.pathology.transforms.post.dictionary import GenerateInstanceBorderd
from tests.utils import TEST_NDARRAYS
from tests.utils.utils import TEST_NDARRAYS

EXCEPTION_TESTS = []
TESTS = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from monai.apps.pathology.transforms.post.array import GenerateInstanceCentroid
from monai.transforms import BoundingRect
from monai.utils import min_version, optional_import
from tests.utils import TEST_NDARRAYS, assert_allclose
from tests.utils.utils import TEST_NDARRAYS, assert_allclose

_, has_skimage = optional_import("skimage", "0.19.3", min_version)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from monai.apps.pathology.transforms.post.dictionary import GenerateInstanceCentroidd
from monai.transforms import BoundingRect
from monai.utils import min_version, optional_import
from tests.utils import TEST_NDARRAYS, assert_allclose
from tests.utils.utils import TEST_NDARRAYS, assert_allclose

_, has_skimage = optional_import("skimage", "0.19.3", min_version)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from monai.apps.pathology.transforms.post.array import GenerateInstanceContour
from monai.transforms import BoundingRect
from monai.utils import min_version, optional_import
from tests.utils import TEST_NDARRAYS, assert_allclose
from tests.utils.utils import TEST_NDARRAYS, assert_allclose

_, has_skimage = optional_import("skimage", "0.19.3", min_version)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from monai.apps.pathology.transforms.post.dictionary import GenerateInstanceContourd
from monai.transforms import BoundingRect
from monai.utils import min_version, optional_import
from tests.utils import TEST_NDARRAYS, assert_allclose
from tests.utils.utils import TEST_NDARRAYS, assert_allclose

_, has_skimage = optional_import("skimage", "0.19.3", min_version)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from parameterized import parameterized

from monai.apps.pathology.transforms.post.array import GenerateInstanceType
from tests.utils import TEST_NDARRAYS, assert_allclose
from tests.utils.utils import TEST_NDARRAYS, assert_allclose

y, x = np.ogrid[0:30, 0:30]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from parameterized import parameterized

from monai.apps.pathology.transforms.post.dictionary import GenerateInstanceTyped
from tests.utils import TEST_NDARRAYS, assert_allclose
from tests.utils.utils import TEST_NDARRAYS, assert_allclose

y, x = np.ogrid[0:30, 0:30]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from monai.apps.pathology.transforms.post.array import GenerateWatershedMarkers
from monai.utils import min_version, optional_import
from tests.utils import TEST_NDARRAYS
from tests.utils.utils import TEST_NDARRAYS

_, has_skimage = optional_import("skimage", "0.19.3", min_version)
_, has_scipy = optional_import("scipy", "1.8.1", min_version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from monai.apps.pathology.transforms.post.dictionary import GenerateWatershedMarkersd
from monai.utils import min_version, optional_import
from tests.utils import TEST_NDARRAYS
from tests.utils.utils import TEST_NDARRAYS

_, has_skimage = optional_import("skimage", "0.19.3", min_version)
_, has_scipy = optional_import("scipy", "1.8.1", min_version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from monai.apps.pathology.transforms.post.array import GenerateWatershedMask
from monai.utils import min_version, optional_import
from tests.utils import TEST_NDARRAYS
from tests.utils.utils import TEST_NDARRAYS

_, has_scipy = optional_import("scipy", "1.8.1", min_version)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from monai.apps.pathology.transforms.post.dictionary import GenerateWatershedMaskd
from monai.utils import min_version, optional_import
from tests.utils import TEST_NDARRAYS
from tests.utils.utils import TEST_NDARRAYS

_, has_scipy = optional_import("scipy", "1.8.1", min_version)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from monai.apps.pathology.transforms.post.array import HoVerNetInstanceMapPostProcessing
from monai.transforms import ComputeHoVerMaps, FillHoles, GaussianSmooth
from monai.utils import min_version, optional_import
from tests.utils import TEST_NDARRAYS, assert_allclose
from tests.utils.utils import TEST_NDARRAYS, assert_allclose

_, has_scipy = optional_import("scipy", "1.8.1", min_version)
_, has_skimage = optional_import("skimage", "0.19.3", min_version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from monai.transforms import ComputeHoVerMaps, FillHoles, GaussianSmooth
from monai.utils import min_version, optional_import
from monai.utils.enums import HoVerNetBranch
from tests.utils import TEST_NDARRAYS, assert_allclose
from tests.utils.utils import TEST_NDARRAYS, assert_allclose

_, has_scipy = optional_import("scipy", "1.8.1", min_version)
_, has_skimage = optional_import("skimage", "0.19.3", min_version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
)
from monai.transforms import ComputeHoVerMaps
from monai.utils import min_version, optional_import
from tests.utils import TEST_NDARRAYS, assert_allclose
from tests.utils.utils import TEST_NDARRAYS, assert_allclose

_, has_scipy = optional_import("scipy", "1.8.1", min_version)
_, has_skimage = optional_import("skimage", "0.19.3", min_version)
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/pathology/transforms/post/test_watershed.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
Watershed,
)
from monai.utils import min_version, optional_import
from tests.utils import TEST_NDARRAYS
from tests.utils.utils import TEST_NDARRAYS

_, has_skimage = optional_import("skimage", "0.19.3", min_version)
_, has_scipy = optional_import("scipy", "1.8.1", min_version)
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/pathology/transforms/post/test_watershedd.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)
from monai.transforms import Compose
from monai.utils import min_version, optional_import
from tests.utils import TEST_NDARRAYS
from tests.utils.utils import TEST_NDARRAYS

_, has_skimage = optional_import("skimage", "0.19.3", min_version)
_, has_scipy = optional_import("scipy", "1.8.1", min_version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
sensitivity_map_expand,
sensitivity_map_reduce,
)
from tests.utils import assert_allclose
from tests.utils.utils import assert_allclose

# no need for checking devices, these functions don't change device format
# reshape test case
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/reconstruction/test_complex_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from monai.apps.reconstruction.complex_utils import complex_abs, complex_conj, complex_mul, convert_to_tensor_complex
from monai.utils.type_conversion import convert_data_type
from tests.utils import TEST_NDARRAYS, assert_allclose
from tests.utils.utils import TEST_NDARRAYS, assert_allclose

# test case for convert_to_tensor_complex
im_complex = [[1.0 + 1.0j, 1.0 + 1.0j], [1.0 + 1.0j, 1.0 + 1.0j]]
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/reconstruction/test_fastmri_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from parameterized import parameterized

from monai.apps.reconstruction.fastmri_reader import FastMRIReader
from tests.utils import SkipIfNoModule, assert_allclose
from tests.utils.utils import SkipIfNoModule, assert_allclose

TEST_CASE1 = [
{
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/reconstruction/test_mri_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from parameterized import parameterized

from monai.apps.reconstruction.mri_utils import root_sum_of_squares
from tests.utils import TEST_NDARRAYS, assert_allclose
from tests.utils.utils import TEST_NDARRAYS, assert_allclose

# root_sum_of_squares
im = [[3.0, 4.0], [3.0, 4.0]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from monai.apps.reconstruction.transforms.dictionary import ReferenceBasedNormalizeIntensityd
from monai.utils.type_conversion import convert_to_numpy
from tests.utils import TEST_NDARRAYS_NO_META_TENSOR, assert_allclose
from tests.utils.utils import TEST_NDARRAYS_NO_META_TENSOR, assert_allclose

# see test_normalize_intensityd for typical tests (like non-zero
# normalization, device test, etc.)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from parameterized import parameterized

from monai.apps.reconstruction.transforms.dictionary import ReferenceBasedSpatialCropd
from tests.utils import TEST_NDARRAYS
from tests.utils.utils import TEST_NDARRAYS

# see test_spatial_cropd for typical tests (like roi_start,
# roi_slices, etc.)
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/test_auto3dseg_bundlegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from monai.bundle.config_parser import ConfigParser
from monai.data import create_test_image_3d
from monai.utils import set_determinism
from tests.utils import (
from tests.utils.utils import (
SkipIfBeforePyTorchVersion,
get_testing_algo_template_path,
skip_if_downloading_fails,
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/test_cross_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from monai.apps import CrossValidation, DecathlonDataset
from monai.data import MetaTensor
from monai.transforms import Compose, EnsureChannelFirstd, LoadImaged, ScaleIntensityd
from tests.utils import skip_if_downloading_fails, skip_if_quick
from tests.utils.utils import skip_if_downloading_fails, skip_if_quick


class TestCrossValidation(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/test_decathlondataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from monai.apps import DecathlonDataset
from monai.data import MetaTensor
from monai.transforms import Compose, EnsureChannelFirstd, LoadImaged, ScaleIntensityd
from tests.utils import skip_if_downloading_fails, skip_if_quick
from tests.utils.utils import skip_if_downloading_fails, skip_if_quick


class TestDecathlonDataset(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/test_download_and_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from parameterized import parameterized

from monai.apps import download_and_extract, download_url, extractall
from tests.utils import skip_if_downloading_fails, skip_if_quick, testing_data_config
from tests.utils.utils import skip_if_downloading_fails, skip_if_quick, testing_data_config


class TestDownloadAndExtract(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/apps/test_mednistdataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from monai.apps import MedNISTDataset
from monai.data import MetaTensor
from monai.transforms import Compose, EnsureChannelFirstd, LoadImaged, ScaleIntensityd
from tests.utils import skip_if_downloading_fails, skip_if_quick
from tests.utils.utils import skip_if_downloading_fails, skip_if_quick

MEDNIST_FULL_DATASET_LENGTH = 58954

Expand Down
2 changes: 1 addition & 1 deletion tests/apps/test_mmar_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from monai.apps.mmars import MODEL_DESC
from monai.apps.mmars.mmars import _get_val
from monai.utils import version_leq
from tests.utils import skip_if_downloading_fails, skip_if_quick
from tests.utils.utils import skip_if_downloading_fails, skip_if_quick

TEST_CASES = [["clara_pt_prostate_mri_segmentation"], ["clara_pt_covid19_ct_lesion_segmentation"]]
TEST_EXTRACT_CASES = [
Expand Down
Loading

0 comments on commit 865dc22

Please sign in to comment.