Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

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

pre-commit-ci[bot]e3d3ec931494
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index a8f774811..e4e6206ee 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -20,7 +20,7 @@ repos:
- id: pyproject-fmt
- repo: https://github.com/charliermarsh/ruff-pre-commit
- rev: v0.0.267
+ rev: v0.0.269
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
@@ -41,7 +41,7 @@ repos:
- "*.bib,*.ipynb"
- repo: https://github.com/PyCQA/docformatter
- rev: v1.6.5
+ rev: v1.7.1
hooks:
- id: docformatter
args: [--in-place, --wrap-summaries=115, --wrap-descriptions=120]
diff --git a/kornia/contrib/vit.py b/kornia/contrib/vit.py
index 6bea7d844..e56aa75fe 100644
--- a/kornia/contrib/vit.py
+++ b/kornia/contrib/vit.py
@@ -2,8 +2,9 @@
Paper: https://paperswithcode.com/paper/an-image-is-worth-16x16-words-transformers-1
-Based on: https://towardsdatascience.com/implementing-visualttransformer-in-pytorch-184f9f16f632
-Added some tricks from https://github.com/rwightman/pytorch-image-models/blob/master/timm/models/vision_transformer.py
+Based on: `https://towardsdatascience.com/implementing-visualttransformer-in-pytorch-184f9f16f632`
+
+Added some tricks from: `https://github.com/rwightman/pytorch-image-models/blob/master/timm/models/vision_transformer.py`
"""
from typing import Any, Callable, Dict, List, Optional, Tuple
diff --git a/kornia/feature/adalam/core.py b/kornia/feature/adalam/core.py
index d5054f063..b26a648e8 100644
--- a/kornia/feature/adalam/core.py
+++ b/kornia/feature/adalam/core.py
@@ -11,8 +11,10 @@ from .utils import dist_matrix, orientation_diff
class AdalamConfig(TypedDict):
- """
- area_ratio: Ratio between seed circle area and image area. Higher values produce more seeds with smaller
+ """A config structure for the Adalam model.
+
+ Args:
+ area_ratio: Ratio between seed circle area and image area. Higher values produce more seeds with smaller
neighborhoods
search_expansion: Expansion factor of the seed circle radius for the purpose of collecting neighborhoods.
Increases neighborhood radius without changing seed distribution
diff --git a/kornia/feature/responses.py b/kornia/feature/responses.py
index 37102856d..a722f1e2c 100644
--- a/kornia/feature/responses.py
+++ b/kornia/feature/responses.py
@@ -293,7 +293,8 @@ def dog_response_single(input: Tensor, sigma1: float = 1.0, sigma2: float = 1.6)
class BlobDoG(Module):
r"""Module that calculates Difference-of-Gaussians blobs.
- See :func:`~kornia.feature.dog_response` for details.
+ See
+ :func: `~kornia.feature.dog_response` for details.
"""
def __init__(self) -> None:
diff --git a/kornia/feature/siftdesc.py b/kornia/feature/siftdesc.py
index cf016c26f..73b627210 100644
--- a/kornia/feature/siftdesc.py
+++ b/kornia/feature/siftdesc.py
@@ -177,7 +177,8 @@ def sift_describe(
) -> Tensor:
r"""Computes the sift descriptor.
- See :class:`~kornia.feature.SIFTDescriptor` for details.
+ See
+ :class: `~kornia.feature.SIFTDescriptor` for details.
"""
return SIFTDescriptor(patch_size, num_ang_bins, num_spatial_bins, rootsift, clipval)(input)
diff --git a/kornia/geometry/linalg.py b/kornia/geometry/linalg.py
index aad59f377..676ed1646 100644
--- a/kornia/geometry/linalg.py
+++ b/kornia/geometry/linalg.py
@@ -76,8 +76,9 @@ def compose_transformations(trans_01: Tensor, trans_12: Tensor) -> Tensor:
def inverse_transformation(trans_12: Tensor) -> Tensor:
- r"""Function that inverts a 4x4 homogeneous transformation
- :math:`T_1^{2} = \begin{bmatrix} R_1 & t_1 \\ \mathbf{0} & 1 \end{bmatrix}`
+ r"""Function that inverts a 4x4 homogeneous transformation.
+
+ :math:`T_1^{2} = \begin{bmatrix} R_1 & t_1 \\ \mathbf{0} & 1 \end{bmatrix}`
The inverse transformation is computed as follows:
@@ -117,9 +118,9 @@ def inverse_transformation(trans_12: Tensor) -> Tensor:
def relative_transformation(trans_01: Tensor, trans_02: Tensor) -> Tensor:
- r"""Function that computes the relative homogeneous transformation from a
- reference transformation :math:`T_1^{0} = \begin{bmatrix} R_1 & t_1 \\
- \mathbf{0} & 1 \end{bmatrix}` to destination :math:`T_2^{0} =
+ r"""Function that computes the relative homogeneous transformation from a reference transformation.
+
+ :math:`T_1^{0} = \begin{bmatrix} R_1 & t_1 \\ \mathbf{0} & 1 \end{bmatrix}` to destination :math:`T_2^{0} =
\begin{bmatrix} R_2 & t_2 \\ \mathbf{0} & 1 \end{bmatrix}`.
The relative transformation is computed as follows:
diff --git a/kornia/geometry/quaternion.py b/kornia/geometry/quaternion.py
index c8aec96a3..939f6b675 100644
--- a/kornia/geometry/quaternion.py
+++ b/kornia/geometry/quaternion.py
@@ -167,7 +167,8 @@ class Quaternion(Module):
def real(self) -> Tensor:
"""Return the real part with shape :math:`(B,)`.
- Alias for :func:`~kornia.geometry.quaternion.Quaternion.w`
+ Alias for
+ :func: `~kornia.geometry.quaternion.Quaternion.w`
"""
return self.w
@@ -188,7 +189,8 @@ class Quaternion(Module):
def scalar(self) -> Tensor:
"""Return a scalar with the real with shape :math:`(B,)`.
- Alias for :func:`~kornia.geometry.quaternion.Quaternion.w`
+ Alias for
+ :func: `~kornia.geometry.quaternion.Quaternion.w`
"""
return self.real
diff --git a/kornia/geometry/subpix/nms.py b/kornia/geometry/subpix/nms.py
index fb184e426..0fec5c2b1 100644
--- a/kornia/geometry/subpix/nms.py
+++ b/kornia/geometry/subpix/nms.py
@@ -160,6 +160,7 @@ def nms2d(input: Tensor, kernel_size: tuple[int, int], mask_only: bool = False)
def nms3d(input: Tensor, kernel_size: tuple[int, int, int], mask_only: bool = False) -> Tensor:
r"""Apply non maxima suppression to filter.
- See :class:`~kornia.feature.NonMaximaSuppression3d` for details.
+ See
+ :class: `~kornia.feature.NonMaximaSuppression3d` for details.
"""
return NonMaximaSuppression3d(kernel_size)(input, mask_only)
diff --git a/kornia/geometry/subpix/spatial_soft_argmax.py b/kornia/geometry/subpix/spatial_soft_argmax.py
index c583f132d..f764d0cb9 100644
--- a/kornia/geometry/subpix/spatial_soft_argmax.py
+++ b/kornia/geometry/subpix/spatial_soft_argmax.py
@@ -125,7 +125,8 @@ def _get_window_grid_kernel3d(d: int, h: int, w: int, device: torch.device = tor
class ConvSoftArgmax2d(Module):
r"""Module that calculates soft argmax 2d per window.
- See :func:`~kornia.geometry.subpix.conv_soft_argmax2d` for details.
+ See
+ :func: `~kornia.geometry.subpix.conv_soft_argmax2d` for details.
"""
def __init__(
@@ -175,7 +176,8 @@ class ConvSoftArgmax2d(Module):
class ConvSoftArgmax3d(Module):
r"""Module that calculates soft argmax 3d per window.
- See :func:`~kornia.geometry.subpix.conv_soft_argmax3d` for details.
+ See
+ :func: `~kornia.geometry.subpix.conv_soft_argmax3d` for details.
"""
def __init__(
@@ -608,7 +610,8 @@ def conv_quad_interp3d(input: Tensor, strict_maxima_bonus: float = 10.0, eps: fl
class ConvQuadInterp3d(Module):
r"""Calculate soft argmax 3d per window.
- See :func:`~kornia.geometry.subpix.conv_quad_interp3d` for details.
+ See
+ :func: `~kornia.geometry.subpix.conv_quad_interp3d` for details.
"""
def __init__(self, strict_maxima_bonus: float = 10.0, eps: float = 1e-7) -> None:
diff --git a/kornia/geometry/transform/thin_plate_spline.py b/kornia/geometry/transform/thin_plate_spline.py
index 3419dda2e..291af5381 100644
--- a/kornia/geometry/transform/thin_plate_spline.py
+++ b/kornia/geometry/transform/thin_plate_spline.py
@@ -26,8 +26,9 @@ def _pair_square_euclidean(tensor1: torch.Tensor, tensor2: torch.Tensor) -> torc
def _kernel_distance(squared_distances: torch.Tensor, eps: float = 1e-8) -> torch.Tensor:
r"""Compute the TPS kernel distance function: :math:`r^2 log(r)`, where `r` is the euclidean distance.
- Since :math:`\log(r) = 1/2 \log(r^2)`, this function takes the squared distance matrix and calculates
- :math:`0.5 r^2 log(r^2)`.
+ Since
+ :math: `\log(r) = 1/2 \log(r^2)`, this function takes the squared distance matrix and calculates
+ :math: `0.5 r^2 log(r^2)`.
"""
# r^2 * log(r) = 1/2 * r^2 * log(r^2)
return 0.5 * squared_distances * squared_distances.add(eps).log()
diff --git a/test/integration/test_conversions.py b/test/integration/test_conversions.py
index 11ed43e9d..28506f18d 100644
--- a/test/integration/test_conversions.py
+++ b/test/integration/test_conversions.py
@@ -322,9 +322,7 @@ class TestQuaternionToRotationMatrixToAngleAxis:
class TestAngleOfRotations:
- """
- See: https://arxiv.org/pdf/1711.02508.pdf
- """
+ """See: https://arxiv.org/pdf/1711.02508.pdf."""
@staticmethod
def matrix_angle_abs(mx: torch.Tensor):