π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
docs: enable ruff D101 and D102 and document the remaining methods (#6306)
Maidul Hasan Masum5fb33451afc0
diff --git a/.github/scripts/check_import_surface.py b/.github/scripts/check_import_surface.pyindex 8866d4245..a90889719 100755--- a/.github/scripts/check_import_surface.py+++ b/.github/scripts/check_import_surface.py@@ -623,6 +623,8 @@ def export_removals(base_ref: str, paths: list[str]) -> dict[str, set[str]]:@dataclassclass FileReport:+ """What one file removed from its ``__all__``, and whether that should fail the check."""+path: strremoved_from_all: set[str]removed_undocumented: set[str]diff --git a/kornia/constants.py b/kornia/constants.pyindex 656655154..98828662b 100644--- a/kornia/constants.py+++ b/kornia/constants.py@@ -97,6 +97,7 @@ class Resample(Enum, metaclass=_KORNIA_EnumMeta):@classmethoddef get(cls, value: TKEnum["Resample"]) -> "Resample":+ """Return the Resample member matching a name, a value or a member."""return _get(cls, value)@@ -110,6 +111,7 @@ class BorderType(Enum, metaclass=_KORNIA_EnumMeta):@classmethoddef get(cls, value: TKEnum["BorderType"]) -> "BorderType":+ """Return the BorderType member matching a name, a value or a member."""return _get(cls, value)@@ -123,6 +125,7 @@ class SamplePadding(Enum, metaclass=_KORNIA_EnumMeta):@classmethoddef get(cls, value: TKEnum["SamplePadding"]) -> "SamplePadding":+ """Return the SamplePadding member matching a name, a value or a member."""return _get(cls, value)@@ -137,6 +140,7 @@ class DType(Enum, metaclass=_KORNIA_EnumMeta):@classmethoddef get(cls, value: Union[str, int, torch.dtype, torch.Tensor, "DType"]) -> "DType":+ """Return the DType member matching a name, a value, a torch dtype, a tensor or a member."""if isinstance(value, torch.dtype):return _get_by_name(cls, str(value)[6:], value)@@ -159,6 +163,7 @@ class DType(Enum, metaclass=_KORNIA_EnumMeta):@classmethoddef to_torch(cls, value: TKEnum["DType"]) -> torch.dtype:+ """Return the torch dtype matching a DType name, value or member."""data = cls.get(value=value)if data == DType.INT64:@@ -181,6 +186,8 @@ class DType(Enum, metaclass=_KORNIA_EnumMeta):# TODO: (low-priority) add INPUT3D, MASK3D, BBOX3D, LAFs etc.class DataKey(Enum, metaclass=_KORNIA_EnumMeta):+ """Kind of data an augmentation container transforms, one per entry of ``data_keys``."""+IMAGE = 0INPUT = 0MASK = 1@@ -193,4 +200,5 @@ class DataKey(Enum, metaclass=_KORNIA_EnumMeta):@classmethoddef get(cls, value: TKEnum["DataKey"]) -> "DataKey":+ """Return the DataKey member matching a name, a value or a member."""return _get(cls, value)diff --git a/kornia/geometry/camera/pinhole.py b/kornia/geometry/camera/pinhole.pyindex 37169696c..03fac4b24 100644--- a/kornia/geometry/camera/pinhole.py+++ b/kornia/geometry/camera/pinhole.py@@ -587,9 +587,11 @@ class PinholeCamerasList(PinholeCamera):return selfdef clone(self) -> "PinholeCamerasList":+ """Return a copy of the list, with each camera cloned."""return PinholeCamerasList([self.get_pinhole(index).clone() for index in range(self.num_cameras)])def scale(self, scale_factor: torch.Tensor) -> "PinholeCamerasList":+ """Scale the cameras by a vector factor along the batch dimension, returning a new list."""return self.clone().scale_(scale_factor)def scale_(self, scale_factor: Union[float, torch.Tensor]) -> "PinholeCamerasList":diff --git a/kornia/losses/hausdorff.py b/kornia/losses/hausdorff.pyindex b7096e7eb..0e00360a0 100644--- a/kornia/losses/hausdorff.py+++ b/kornia/losses/hausdorff.py@@ -202,7 +202,8 @@ class HausdorffERLoss(_HausdorffERLossBase):@staticmethoddef max_pool(x: torch.Tensor) -> torch.Tensor:- # Global max over the spatial dims; equals ``nn.AdaptiveMaxPool2d(1)`` but has an ONNX lowering.+ """Take the global maximum over the spatial dimensions, keeping them with size one."""+ # Equals ``nn.AdaptiveMaxPool2d(1)`` but has an ONNX lowering.return x.amax(dim=(-2, -1), keepdim=True)def get_kernel(self) -> torch.Tensor:@@ -276,7 +277,8 @@ class HausdorffERLoss3D(_HausdorffERLossBase):@staticmethoddef max_pool(x: torch.Tensor) -> torch.Tensor:- # Global max over the volume dims; equals ``nn.AdaptiveMaxPool3d(1)`` but has an ONNX lowering.+ """Take the global maximum over the volume dimensions, keeping them with size one."""+ # Equals ``nn.AdaptiveMaxPool3d(1)`` but has an ONNX lowering.return x.amax(dim=(-3, -2, -1), keepdim=True)def get_kernel(self) -> torch.Tensor:diff --git a/pyproject.toml b/pyproject.tomlindex 76152f123..f78afd078 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -299,8 +299,6 @@ ignore = ["UP045", # Use `X | None` for type annotations"RUF005", # Consider `(*points_in_cam_canonical.shape[:-1], 1)` instead of concatenation. Note: breaks JIT."D100", # Allow Undocumented public module- "D101", # TODO: Undocumented public class- "D102", # TODO: Undocumented public method"D104", # TODO: Undocumented public package"D105", # Allow Undocumented magic method"D107", # TODO: Undocumented public init