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
2 changes: 1 addition & 1 deletion docs/source/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Profiling

Deprecated
----------
.. automodule:: monai.utils.deprecated
.. automodule:: monai.utils.deprecate_utils
:members:


Expand Down
1 change: 0 additions & 1 deletion monai/losses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
GeneralizedDiceLoss,
GeneralizedWassersteinDiceLoss,
MaskedDiceLoss,
dice,
dice_ce,
dice_focal,
generalized_dice,
Expand Down
2 changes: 1 addition & 1 deletion monai/losses/dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ def forward(self, input: torch.Tensor, target: torch.Tensor) -> torch.Tensor:
return total_loss


dice = Dice = DiceLoss
Dice = DiceLoss
dice_ce = DiceCELoss
dice_focal = DiceFocalLoss
generalized_dice = GeneralizedDiceLoss
Expand Down
2 changes: 1 addition & 1 deletion monai/networks/blocks/convolutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from monai.networks.blocks import ADN
from monai.networks.layers.convutils import same_padding, stride_minus_kernel_padding
from monai.networks.layers.factories import Conv
from monai.utils.deprecated import deprecated_arg
from monai.utils.deprecate_utils import deprecated_arg


class Convolution(nn.Sequential):
Expand Down
7 changes: 3 additions & 4 deletions monai/networks/nets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .ahnet import AHnet, Ahnet, AHNet, ahnet
from .ahnet import AHnet, Ahnet, AHNet
from .autoencoder import AutoEncoder
from .basic_unet import BasicUNet, BasicUnet, Basicunet, basicunet
from .classifier import Classifier, Critic, Discriminator
Expand All @@ -24,13 +24,12 @@
Densenet201,
DenseNet264,
Densenet264,
densenet,
densenet121,
densenet169,
densenet201,
densenet264,
)
from .dynunet import DynUNet, DynUnet, Dynunet, dynunet
from .dynunet import DynUNet, DynUnet, Dynunet
from .efficientnet import (
BlockArgs,
EfficientNet,
Expand Down Expand Up @@ -80,7 +79,7 @@
)
from .torchvision_fc import TorchVisionFCModel, TorchVisionFullyConvModel
from .transchex import BertAttention, BertMixedLayer, BertOutput, BertPreTrainedModel, MultiModal, Pooler, Transchex
from .unet import UNet, Unet, unet
from .unet import UNet, Unet
from .unetr import UNETR
from .varautoencoder import VarAutoEncoder
from .vit import ViT
Expand Down
4 changes: 2 additions & 2 deletions monai/networks/nets/ahnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from monai.networks.blocks.fcn import FCN
from monai.networks.layers.factories import Act, Conv, Norm, Pool

__all__ = ["AHnet", "Ahnet", "ahnet", "AHNet"]
__all__ = ["AHnet", "Ahnet", "AHNet"]


class Bottleneck3x3x1(nn.Module):
Expand Down Expand Up @@ -559,4 +559,4 @@ def copy_bn_param(module2d, module3d):
p3d.data[:] = p2d.data[:] # Two parameter gamma and beta


AHnet = Ahnet = ahnet = AHNet
AHnet = Ahnet = AHNet
3 changes: 1 addition & 2 deletions monai/networks/nets/densenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

__all__ = [
"DenseNet",
"densenet",
"Densenet",
"DenseNet121",
"densenet121",
Expand Down Expand Up @@ -390,7 +389,7 @@ def __init__(
raise NotImplementedError("Currently PyTorch Hub does not provide densenet264 pretrained models.")


Densenet = densenet = DenseNet
Densenet = DenseNet
Densenet121 = densenet121 = DenseNet121
Densenet169 = densenet169 = DenseNet169
Densenet201 = densenet201 = DenseNet201
Expand Down
4 changes: 2 additions & 2 deletions monai/networks/nets/dynunet.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from monai.networks.blocks.dynunet_block import UnetBasicBlock, UnetOutBlock, UnetResBlock, UnetUpBlock

__all__ = ["DynUNet", "DynUnet", "Dynunet", "dynunet"]
__all__ = ["DynUNet", "DynUnet", "Dynunet"]


class DynUNetSkipLayer(nn.Module):
Expand Down Expand Up @@ -308,4 +308,4 @@ def initialize_weights(module):
module.bias = nn.init.constant_(module.bias, 0)


DynUnet = Dynunet = dynunet = DynUNet
DynUnet = Dynunet = DynUNet
4 changes: 2 additions & 2 deletions monai/networks/nets/unet.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from monai.networks.layers.simplelayers import SkipConnection
from monai.utils import alias, deprecated_arg, export

__all__ = ["UNet", "Unet", "unet"]
__all__ = ["UNet", "Unet"]


@export("monai.networks.nets")
Expand Down Expand Up @@ -282,4 +282,4 @@ def forward(self, x: torch.Tensor) -> torch.Tensor:
return x


Unet = unet = UNet
Unet = UNet
2 changes: 1 addition & 1 deletion monai/networks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import torch
import torch.nn as nn

from monai.utils.deprecated import deprecated_arg
from monai.utils.deprecate_utils import deprecated_arg

__all__ = [
"one_hot",
Expand Down
2 changes: 1 addition & 1 deletion monai/transforms/intensity/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
ensure_tuple_size,
fall_back_tuple,
)
from monai.utils.deprecated import deprecated_arg
from monai.utils.deprecate_utils import deprecated_arg
from monai.utils.enums import TransformBackends
from monai.utils.type_conversion import convert_to_tensor, get_equivalent_dtype

Expand Down
2 changes: 1 addition & 1 deletion monai/transforms/intensity/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
from monai.transforms.transform import MapTransform, RandomizableTransform
from monai.transforms.utils import is_positive
from monai.utils import ensure_tuple, ensure_tuple_rep
from monai.utils.deprecated import deprecated_arg
from monai.utils.deprecate_utils import deprecated_arg

__all__ = [
"RandGaussianNoised",
Expand Down
2 changes: 1 addition & 1 deletion monai/transforms/spatial/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
issequenceiterable,
optional_import,
)
from monai.utils.deprecated import deprecated_arg
from monai.utils.deprecate_utils import deprecated_arg
from monai.utils.enums import TransformBackends
from monai.utils.module import look_up_option
from monai.utils.type_conversion import convert_data_type, convert_to_dst_type
Expand Down
2 changes: 1 addition & 1 deletion monai/transforms/spatial/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
ensure_tuple_rep,
fall_back_tuple,
)
from monai.utils.deprecated import deprecated_arg
from monai.utils.deprecate_utils import deprecated_arg
from monai.utils.enums import InverseKeys
from monai.utils.module import optional_import
from monai.utils.type_conversion import convert_data_type, convert_to_dst_type
Expand Down
2 changes: 1 addition & 1 deletion monai/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# have to explicitly bring these in here to resolve circular import issues
from .aliases import alias, resolve_name
from .decorators import MethodReplacer, RestartGenerator
from .deprecated import DeprecatedError, deprecated, deprecated_arg
from .deprecate_utils import DeprecatedError, deprecated, deprecated_arg
from .dist import evenly_divisible_all_gather, get_dist_device, string_list_all_gather
from .enums import (
Average,
Expand Down
File renamed without changes.
39 changes: 39 additions & 0 deletions tests/test_alias.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2020 - 2021 MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import glob
import inspect
import os
import unittest

from monai.utils import optional_import


class TestModuleAlias(unittest.TestCase):
"""check that 'import monai.xx.file_name' returns a module"""

def test_files(self):
src_dir = os.path.dirname(os.path.dirname(__file__))
monai_dir = os.path.join(src_dir, "monai")
py_files = glob.glob(os.path.join(monai_dir, "**", "*.py"), recursive=True)
for x in py_files:
if os.path.basename(x).startswith("_"):
continue
mod_name = x[len(src_dir) : -3] # create relative path
mod_name = mod_name[1:].replace(mod_name[0], ".")
mod, cls = mod_name.rsplit(".", 1)
obj, exist = optional_import(mod, name=cls)
if exist:
self.assertTrue(inspect.ismodule(obj), msg=mod_name)


if __name__ == "__main__":
unittest.main()