Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

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

pre-commit-ci[bot]af1519a8b1bd
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index c0c1f8844..3f61f556a 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -66,7 +66,7 @@ repos:
- "B101,B311"
- repo: https://github.com/PyCQA/docformatter
- rev: v1.5.1
+ rev: v1.6.1-rc1
hooks:
- id: docformatter
args: [--in-place, --wrap-summaries=115, --wrap-descriptions=120]
diff --git a/kornia/augmentation/_2d/base.py b/kornia/augmentation/_2d/base.py
index d022fc6e9..f131d6556 100644
--- a/kornia/augmentation/_2d/base.py
+++ b/kornia/augmentation/_2d/base.py
@@ -70,7 +70,6 @@ class RigidAffineAugmentationBase2D(AugmentationBase2D):
def generate_transformation_matrix(self, input: Tensor, params: Dict[str, Tensor], flags: Dict[str, Any]) -> Tensor:
"""Generate transformation matrices with the given input and param settings."""
-
batch_prob = params['batch_prob']
to_apply = batch_prob > 0.5 # NOTE: in case of Relaxed Distributions.
diff --git a/kornia/augmentation/utils/helpers.py b/kornia/augmentation/utils/helpers.py
index 581ccf613..baae71b9e 100644
--- a/kornia/augmentation/utils/helpers.py
+++ b/kornia/augmentation/utils/helpers.py
@@ -234,11 +234,11 @@ def _adapted_uniform(
) -> Tensor:
r"""The uniform sampling function that accepts 'same_on_batch'.
- If same_on_batch is True, all values generated will be exactly same given a batch_size (shape[0]).
- By default, same_on_batch is set to False.
+ If same_on_batch is True, all values generated will be exactly same given a batch_size (shape[0]). By default,
+ same_on_batch is set to False.
- By default, sampling happens on the default device and dtype. If low/high is a tensor, sampling will happen
- in the same device/dtype as low/high tensor.
+ By default, sampling happens on the default device and dtype. If low/high is a tensor, sampling will happen in the
+ same device/dtype as low/high tensor.
"""
device, dtype = _extract_device_dtype(
[low if isinstance(low, Tensor) else None, high if isinstance(high, Tensor) else None]
@@ -259,11 +259,11 @@ def _adapted_beta(
) -> Tensor:
r"""The beta sampling function that accepts 'same_on_batch'.
- If same_on_batch is True, all values generated will be exactly same given a batch_size (shape[0]).
- By default, same_on_batch is set to False.
+ If same_on_batch is True, all values generated will be exactly same given a batch_size (shape[0]). By default,
+ same_on_batch is set to False.
- By default, sampling happens on the default device and dtype. If a/b is a tensor, sampling will happen
- in the same device/dtype as a/b tensor.
+ By default, sampling happens on the default device and dtype. If a/b is a tensor, sampling will happen in the same
+ device/dtype as a/b tensor.
"""
device, dtype = _extract_device_dtype([a if isinstance(a, Tensor) else None, b if isinstance(b, Tensor) else None])
a = as_tensor(a, device=device, dtype=dtype)
diff --git a/kornia/color/lab.py b/kornia/color/lab.py
index d60cd25f9..d944d898c 100644
--- a/kornia/color/lab.py
+++ b/kornia/color/lab.py
@@ -1,16 +1,15 @@
+"""The RGB to Lab color transformations were translated from scikit image's rgb2lab and lab2rgb.
+
+https://github.com/scikit-image/scikit-image/blob/a48bf6774718c64dade4548153ae16065b595ca9/skimage/color/colorconv.py
+"""
+
+
import torch
import torch.nn as nn
from .rgb import linear_rgb_to_rgb, rgb_to_linear_rgb
from .xyz import rgb_to_xyz, xyz_to_rgb
-"""
-The RGB to Lab color transformations were translated from scikit image's rgb2lab and lab2rgb
-
-https://github.com/scikit-image/scikit-image/blob/a48bf6774718c64dade4548153ae16065b595ca9/skimage/color/colorconv.py
-
-"""
-
def rgb_to_lab(image: torch.Tensor) -> torch.Tensor:
r"""Convert a RGB image to Lab.
diff --git a/kornia/color/luv.py b/kornia/color/luv.py
index 492acdebf..4acafabfe 100644
--- a/kornia/color/luv.py
+++ b/kornia/color/luv.py
@@ -1,3 +1,9 @@
+"""The RGB to Luv color transformations were translated from scikit image's rgb2luv and luv2rgb.
+
+https://github.com/scikit-image/scikit-image/blob/a48bf6774718c64dade4548153ae16065b595ca9/skimage/color/colorconv.py
+"""
+
+
from typing import Tuple
import torch
@@ -6,13 +12,6 @@ import torch.nn as nn
from .rgb import linear_rgb_to_rgb, rgb_to_linear_rgb
from .xyz import rgb_to_xyz, xyz_to_rgb
-"""
-The RGB to Luv color transformations were translated from scikit image's rgb2luv and luv2rgb
-
-https://github.com/scikit-image/scikit-image/blob/a48bf6774718c64dade4548153ae16065b595ca9/skimage/color/colorconv.py
-
-"""
-
def rgb_to_luv(image: torch.Tensor, eps: float = 1e-12) -> torch.Tensor:
r"""Convert a RGB image to Luv.
diff --git a/kornia/core/check.py b/kornia/core/check.py
index a437f999b..2f4d01b30 100644
--- a/kornia/core/check.py
+++ b/kornia/core/check.py
@@ -46,7 +46,6 @@ def KORNIA_CHECK_SHAPE(x: Tensor, shape: list[str]) -> None:
>>> x = torch.rand(2, 3, 4, 4)
>>> KORNIA_CHECK_SHAPE(x, ["2","3", "H", "W"]) # explicit
"""
-
if '*' == shape[0]:
shape_to_check = shape[1:]
x_shape_to_check = x.shape[-len(shape) + 1 :]
diff --git a/kornia/feature/adalam/utils.py b/kornia/feature/adalam/utils.py
index de647aef4..bb1bbd40a 100644
--- a/kornia/feature/adalam/utils.py
+++ b/kornia/feature/adalam/utils.py
@@ -6,8 +6,8 @@ from kornia.core import Tensor
def arange_sequence(ranges: Tensor) -> Tensor:
- """
- returns a sequence of the ranges specified by the argument.
+ """returns a sequence of the ranges specified by the argument.
+
Example:
[2, 5, 1, 2] -> [0, 1, 0, 1, 2, 3, 4, 0, 0, 1]
"""
diff --git a/kornia/feature/integrated.py b/kornia/feature/integrated.py
index bf3e6354f..eda7662f8 100644
--- a/kornia/feature/integrated.py
+++ b/kornia/feature/integrated.py
@@ -143,7 +143,8 @@ class SIFTFeature(LocalFeature):
"""Convenience module, which implements DoG detector + (Root)SIFT descriptor.
Using `kornia.feature.MultiResolutionDetector` without blur pyramid Still not as good as OpenCV/VLFeat because of
- https://github.com/kornia/kornia/pull/884, but we are working on it
+ https://github.com/kornia/kornia/pull/884,
+ but we are working on it
"""
def __init__(
diff --git a/kornia/geometry/subpix/dsnt.py b/kornia/geometry/subpix/dsnt.py
index 3c7c5bde6..28b8e84a5 100644
--- a/kornia/geometry/subpix/dsnt.py
+++ b/kornia/geometry/subpix/dsnt.py
@@ -1,8 +1,9 @@
-from __future__ import annotations
-
r"""Implementation of "differentiable spatial to numerical" (soft-argmax) operations, as described in the paper
"Numerical Coordinate Regression with Convolutional Neural Networks" by Nibali et al."""
+
+from __future__ import annotations
+
import torch
import torch.nn.functional as F