Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

Refactor unnecessary `else` / `elif` when `if` block has a `raise` statement (#1088)

deepsource-autofix[bot]8cd573959f12
diff --git a/kornia/augmentation/container/augment.py b/kornia/augmentation/container/augment.py
index 3ebe893f3..4771313ec 100644
--- a/kornia/augmentation/container/augment.py
+++ b/kornia/augmentation/container/augment.py
@@ -93,7 +93,7 @@ class AugmentationSequential(ImageSequential):
) -> torch.Tensor:
if isinstance(module, GeometricAugmentationBase2D) and param is None:
raise ValueError(f"Transformation matrix for {module} has not been computed.")
- elif isinstance(module, GeometricAugmentationBase2D) and param is not None:
+ if isinstance(module, GeometricAugmentationBase2D) and param is not None:
input = transform_boxes(module.get_transformation_matrix(input, param), input, mode)
else:
pass # No need to update anything
@@ -104,7 +104,7 @@ class AugmentationSequential(ImageSequential):
) -> torch.Tensor:
if isinstance(module, GeometricAugmentationBase2D) and param is None:
raise ValueError(f"Transformation matrix for {module} has not been computed.")
- elif isinstance(module, GeometricAugmentationBase2D) and param is not None:
+ if isinstance(module, GeometricAugmentationBase2D) and param is not None:
input = transform_points(module.get_transformation_matrix(input, param), input)
else:
pass # No need to update anything
diff --git a/kornia/filters/kernels.py b/kornia/filters/kernels.py
index f2bae1d92..3612d2d12 100644
--- a/kornia/filters/kernels.py
+++ b/kornia/filters/kernels.py
@@ -327,7 +327,7 @@ def get_spatial_gradient_kernel3d(mode: str, order: int, device=torch.device('cp
)
if mode == 'sobel':
raise NotImplementedError("Sobel kernel for 3d gradient is not implemented yet")
- elif mode == 'diff' and order == 1:
+ if mode == 'diff' and order == 1:
kernel = get_diff_kernel3d(device, dtype)
elif mode == 'diff' and order == 2:
kernel = get_diff_kernel3d_2nd_order(device, dtype)