π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
fix minor mypy issues across versions (#1132)
Edgar Riba91dcef465110
diff --git a/kornia/augmentation/container/augment.py b/kornia/augmentation/container/augment.pyindex 852346dae..0865d1d8c 100644--- a/kornia/augmentation/container/augment.py+++ b/kornia/augmentation/container/augment.py@@ -158,7 +158,8 @@ class AugmentationSequential(ImageSequential):if param is not None:assert module_name == param.nameif module is None:- module = self.get_submodule(module_name)+ # TODO (jian): double check why typing is crashing+ module = self.get_submodule(module_name) # type: ignoreif DataKey.get(dcate) in [DataKey.INPUT]:return self.apply_to_input(input, module_name, module, param)if DataKey.get(dcate) in [DataKey.MASK]:diff --git a/kornia/augmentation/container/image.py b/kornia/augmentation/container/image.pyindex 43ba35a29..197f4e444 100644--- a/kornia/augmentation/container/image.py+++ b/kornia/augmentation/container/image.py@@ -153,7 +153,8 @@ class ImageSequential(nn.Sequential):param: Optional[ParamItem] = None,) -> Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:if module is None:- module = self.get_submodule(module_name)+ # TODO (jian): double check why typing is crashing+ module = self.get_submodule(module_name) # type: ignoreif param is not None:assert module_name == param.name_param = param.datadiff --git a/kornia/geometry/camera/stereo.py b/kornia/geometry/camera/stereo.pyindex a647150c2..469417847 100644--- a/kornia/geometry/camera/stereo.py+++ b/kornia/geometry/camera/stereo.py@@ -56,14 +56,14 @@ class StereoCamera:of shape :math:`(B, 3, 4)`"""# Ensure correct shapes- if rectified_left_camera.ndim != 3:+ if len(rectified_left_camera.shape) != 3:raise StereoException(- f"Expected 'rectified_left_camera' to have 3 dimensions. " f"Got {rectified_left_camera.ndim}."+ f"Expected 'rectified_left_camera' to have 3 dimensions. " f"Got {rectified_left_camera.shape}.")- if rectified_right_camera.ndim != 3:+ if len(rectified_right_camera.shape) != 3:raise StereoException(- f"Expected 'rectified_right_camera' to have 3 dimension. " f"Got {rectified_right_camera.ndim}."+ f"Expected 'rectified_right_camera' to have 3 dimension. " f"Got {rectified_right_camera.shape}.")if rectified_left_camera.shape[:1] == (3, 4):@@ -231,8 +231,8 @@ def _check_disparity_tensor(disparity_tensor: torch.Tensor):f"Expected 'disparity_tensor' to be an instance of torch.Tensor but got {type(disparity_tensor)}.")- if disparity_tensor.ndim != 4:- raise StereoException(f"Expected 'disparity_tensor' to have 4 dimensions." f"Got {disparity_tensor.ndim}.")+ if len(disparity_tensor.shape) != 4:+ raise StereoException(f"Expected 'disparity_tensor' to have 4 dimensions." f"Got {disparity_tensor.shape}.")if disparity_tensor.shape[-1] != 1:raise StereoException(@@ -257,8 +257,8 @@ def _check_Q_matrix(Q_matrix: torch.Tensor):if not isinstance(Q_matrix, torch.Tensor):raise StereoException(f"Expected 'Q_matrix' to be an instance of torch.Tensor but got {type(Q_matrix)}.")- if not Q_matrix.ndim == 3:- raise StereoException(f"Expected 'Q_matrix' to have 3 dimenstions." f"Got {Q_matrix.ndim}")+ if not len(Q_matrix.shape) == 3:+ raise StereoException(f"Expected 'Q_matrix' to have 3 dimenstions." f"Got {Q_matrix.shape}")if not Q_matrix.shape[1:] == (4, 4):raise StereoException(diff --git a/kornia/testing/__init__.py b/kornia/testing/__init__.pyindex becd68dad..9d1aaa752 100644--- a/kornia/testing/__init__.py+++ b/kornia/testing/__init__.py@@ -134,7 +134,7 @@ def _get_precision_by_name(try:# torch.testing.assert_close is only available for torch>=1.9- from torch.testing import assert_close as _assert_close+ from torch.testing import assert_close as _assert_close # type: ignorefrom torch.testing._core import _get_default_tolerancedef assert_close(