Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

fix(geometry): stop pose.py leaking uuid, annotations, torch and check_matrix_shape into kornia.geometry (#4986)

niukanen1ff5952f8f123
diff --git a/changelog.d/4986.breaking.md b/changelog.d/4986.breaking.md
new file mode 100644
index 000000000..a113fa094
--- /dev/null
+++ b/changelog.d/4986.breaking.md
@@ -0,0 +1,7 @@
+`kornia.geometry.pose` now defines `__all__ = ["NamedPose"]`, so the stdlib module `uuid`, the `__future__` feature
+`annotations`, `torch` and the validation helper `check_matrix_shape` (renamed to `_check_matrix_shape`) are no longer
+star-imported into `kornia.geometry`. `kornia.geometry.Quaternion` stays available through an explicit re-export in
+`kornia/geometry/__init__.py`, so it no longer depends on the leak. None of the removed names is documented, and per
+`docs/source/get-started/stability.rst` undocumented helpers are private regardless of importability. The names are
+dropped from `tests/api_surface.json` in this change. `kornia.geometry.torch` remains on the surface until
+`kornia/geometry/homography.py` also defines an `__all__`. (#4939)
diff --git a/docs/export_support/cases_geomA.py b/docs/export_support/cases_geomA.py
index f5be67588..c8de22d1e 100644
--- a/docs/export_support/cases_geomA.py
+++ b/docs/export_support/cases_geomA.py
@@ -1223,7 +1223,7 @@ CASES += [
tags=("points",),
note="3x3 -> Se2 path; points (N,2)",
),
- case("pose.check_matrix_shape", G, None, [], skip="validation helper, returns None"),
+ case("pose._check_matrix_shape", G, None, [], skip="validation helper, returns None"),
case(
"pose.Quaternion/Se2/Se3/So2/So3",
G,
diff --git a/docs/source/_data/export_support.json b/docs/source/_data/export_support.json
index f22a38b24..528458efb 100644
--- a/docs/source/_data/export_support.json
+++ b/docs/source/_data/export_support.json
@@ -8744,11 +8744,11 @@
"export": "n/a",
"export_detail": "validation helper, returns None",
"graph_breaks": 0,
- "name": "pose.check_matrix_shape",
+ "name": "pose._check_matrix_shape",
"note": "",
"onnx": "n/a",
"onnx_detail": "validation helper, returns None",
- "operator": "check_matrix_shape",
+ "operator": "_check_matrix_shape",
"package": "kornia.geometry",
"ref": "",
"section": "pose",
diff --git a/kornia/geometry/__init__.py b/kornia/geometry/__init__.py
index 923ed1ac7..c054e12e0 100644
--- a/kornia/geometry/__init__.py
+++ b/kornia/geometry/__init__.py
@@ -34,6 +34,7 @@ from .line import *
from .plane import *
from .pointcloud import *
from .pose import *
+from .quaternion import Quaternion
from .ransac import *
from .solvers import *
from .subpix import *
diff --git a/kornia/geometry/pose.py b/kornia/geometry/pose.py
index b296ee722..ba2927514 100644
--- a/kornia/geometry/pose.py
+++ b/kornia/geometry/pose.py
@@ -24,8 +24,10 @@ import torch
from kornia.geometry.liegroup import Se2, Se3, So2, So3
from kornia.geometry.quaternion import Quaternion
+__all__ = ["NamedPose"]
-def check_matrix_shape(matrix: torch.Tensor, matrix_type: str = "R") -> None:
+
+def _check_matrix_shape(matrix: torch.Tensor, matrix_type: str = "R") -> None:
"""Verify matrix shape based on type."""
target_shapes = []
if matrix_type == "R":
@@ -175,7 +177,7 @@ class NamedPose:
if isinstance(rotation, So2):
return cls(Se2(rotation, translation), frame_src, frame_dst)
if isinstance(rotation, torch.Tensor):
- check_matrix_shape(rotation)
+ _check_matrix_shape(rotation)
dim = rotation.shape[-1]
batch_shape = rotation.shape[:-2]
if translation.shape != rotation.shape[:-1]:
@@ -219,7 +221,7 @@ class NamedPose:
frame_src: frame_a -> frame_dst: frame_b)
"""
- check_matrix_shape(matrix, matrix_type="RT")
+ _check_matrix_shape(matrix, matrix_type="RT")
dim = matrix.shape[-1]
if dim == 3:
return cls(Se2.from_matrix(matrix), frame_src, frame_dst)
diff --git a/tests/api_surface.json b/tests/api_surface.json
index f4533f0da..92fbea934 100644
--- a/tests/api_surface.json
+++ b/tests/api_surface.json
@@ -372,7 +372,6 @@
"angle_axis_to_quaternion",
"angle_axis_to_rotation_matrix",
"angle_to_rotation_matrix",
- "annotations",
"axis_angle_to_quaternion",
"axis_angle_to_rotation_matrix",
"batched_dot_product",
@@ -396,7 +395,6 @@
"cart2pol",
"center_crop",
"center_crop3d",
- "check_matrix_shape",
"compose_transformations",
"compute_correspond_epilines",
"conv_quad_interp3d",
@@ -594,7 +592,6 @@
"unproject_points",
"unproject_points_orthographic",
"unproject_points_z1",
- "uuid",
"validate_bbox",
"validate_bbox3d",
"vector",