Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

[pre-commit.ci] pre-commit suggestions (#2990)

pre-commit-ci[bot]776b26d3f355
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 166cb24ff..c7c041d5b 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -20,7 +20,7 @@ repos:
- id: pyproject-fmt
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: v0.5.7
+ rev: v0.6.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
diff --git a/kornia/augmentation/_2d/geometric/crop.py b/kornia/augmentation/_2d/geometric/crop.py
index ed8e56c78..c95196eef 100644
--- a/kornia/augmentation/_2d/geometric/crop.py
+++ b/kornia/augmentation/_2d/geometric/crop.py
@@ -120,17 +120,13 @@ class RandomCrop(GeometricAugmentationBase2D):
# If crop width is larger than input width pad equally left and right
if needed_padding[1] > 0:
# Only use the extra padding if actually needed after possible fixed padding
- if needed_padding[1] > padding[0]:
- padding[0] = needed_padding[1]
- if needed_padding[1] > padding[1]:
- padding[1] = needed_padding[1]
+ padding[0] = max(needed_padding[1], padding[0])
+ padding[1] = max(needed_padding[1], padding[1])
# If crop height is larger than input height pad equally top and bottom
if needed_padding[0] > 0:
# Only use the extra padding if actually needed after possible fixed padding
- if needed_padding[0] > padding[2]:
- padding[2] = needed_padding[0]
- if needed_padding[0] > padding[3]:
- padding[3] = needed_padding[0]
+ padding[2] = max(needed_padding[0], padding[2])
+ padding[3] = max(needed_padding[0], padding[3])
return padding
def precrop_padding(