Is your feature request related to a problem? Please describe.
NdarrayOrTensor should be replaced by a type variable such as NdarrayTensor
this will ensure advanced type checks for correctness however it might not be supported by all the tools such as pytype, mypy
Additional context
|
NdarrayTensor = TypeVar("NdarrayTensor", np.ndarray, torch.Tensor) |
|
"""NdarrayTensor |
|
|
|
Generic type which can represent either a numpy.ndarray or a torch.Tensor |
|
Unlike Union can create a dependence between parameter(s) / return(s) |
|
""" |
|
|
|
NdarrayOrTensor = Union[np.ndarray, torch.Tensor] |
|
"""NdarrayOrTensor |
|
|
|
Union of numpy.ndarray and torch.Tensor to be used for typing |
|
""" |
this is a follow up of #2815
Is your feature request related to a problem? Please describe.
NdarrayOrTensorshould be replaced by a type variable such asNdarrayTensorthis will ensure advanced type checks for correctness however it might not be supported by all the tools such as pytype, mypy
Additional context
MONAI/monai/config/type_definitions.py
Lines 65 to 76 in 93d467d
this is a follow up of #2815