Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8185 - Refactor test #8231

Open
wants to merge 32 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
075ec11
Eliminates code repetition
garciadias Nov 20, 2024
e8d3e19
Replace relative import with absolute
garciadias Nov 20, 2024
d4b01e6
Directly tests export_ckpt function instead of using command_line_tests
garciadias Nov 21, 2024
bfc68a4
Style fix
garciadias Nov 21, 2024
10eb2af
Merge branch 'dev' into 8185-tests-refactor
garciadias Nov 21, 2024
55fcd22
Revert "Style fix"
garciadias Nov 23, 2024
ba16743
Revert "Replace relative import with absolute"
garciadias Nov 23, 2024
1667eb7
Revert "Directly tests export_ckpt function instead of using command_…
garciadias Nov 23, 2024
702e740
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 24, 2024
9a2c2f4
moves tests to their corresponding folder
garciadias Nov 28, 2024
f2cf158
replace relative imports with absolute import
garciadias Nov 28, 2024
b3fd8e9
Change locating integrations
garciadias Nov 28, 2024
114fc72
Corrects the download path for integration tests
garciadias Nov 28, 2024
626e050
Move array/* and dictionary/* files to parent directory
garciadias Dec 2, 2024
4c6b59c
Move single files on their parent folders
garciadias Dec 2, 2024
050e71b
Merge remote-tracking branch 'upstream/dev' into dev
garciadias Dec 2, 2024
7d68938
Merge branch 'dev' into 8185-tests-refactor
garciadias Dec 2, 2024
3508211
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 2, 2024
2d55074
Recovers deleted file
garciadias Dec 3, 2024
6e9c66e
Merge remote-tracking branch 'upstream/dev' into 8185-tests-refactor
garciadias Dec 3, 2024
fa5c75c
Merge remote-tracking branch 'upstream/dev' into dev
garciadias Dec 4, 2024
dda65c4
Merge branch 'dev' into 8185-tests-refactor
garciadias Dec 4, 2024
bf82225
Start fixing path issues after moving files
garciadias Dec 6, 2024
56c2a48
Keep fixing data paths
garciadias Dec 9, 2024
98d3ab2
rerouting paths
garciadias Dec 11, 2024
6d1af88
Merge remote-tracking branch 'origin/8185-tests-refactor' into 8185-t…
garciadias Dec 11, 2024
a0d2395
Solve many more issues
garciadias Dec 11, 2024
9977e98
Merge remote-tracking branch 'origin/8185-tests-refactor' into 8185-t…
garciadias Dec 11, 2024
8831dc0
reorder imports
garciadias Dec 11, 2024
58c461c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 11, 2024
bb85f53
Fix path issues
garciadias Dec 11, 2024
865dc22
Move utils inside utils to avoid coflict
garciadias Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ temp/
.DS_Store

# temporary testing data MedNIST
tests/integration/testing_data/MedNIST*
tests/testing_data/MedNIST*
tests/testing_data/*Hippocampus*
tests/testing_data/*.tiff
Expand Down
2 changes: 1 addition & 1 deletion runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ if [ $doNetTests = true ]
then
set +e # disable exit on failure so that diagnostics can be given on failure
echo "${separator}${blue}integration${noColor}"
for i in tests/*integration_*.py
for i in tests/integration/*.py
do
echo "$i"
${cmdPrefix}${cmd} "$i"
Expand Down
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
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
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
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
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
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
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
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
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
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
File renamed without changes.
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 @@ -21,7 +21,7 @@
from monai.data import MetaTensor
from monai.inferers import sliding_window_inference
from monai.utils import optional_import
from tests.test_sliding_window_inference import TEST_CASES
from tests.inferers.test_sliding_window_inference import TEST_CASES

_, has_tqdm = optional_import("tqdm")

Expand All @@ -36,7 +36,6 @@


class TestSlidingWindowHoVerNetInference(unittest.TestCase):

@parameterized.expand(TEST_CASES_PADDING)
def test_sliding_window_with_padding(
self, key, image_shape, roi_shape, sw_batch_size, overlap, mode, device, extra_input_padding
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
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
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
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
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
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
File renamed without changes.
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
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
File renamed without changes.
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
Loading
Loading