Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

test: fix always-true shape assertions and enforce Ruff SIM222 (#5333)

Alex0f390503a9e9
diff --git a/pyproject.toml b/pyproject.toml
index d70ee89c2..23f35ddb7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -226,6 +226,7 @@ select = [
"RSE", # flake8-raise
"RUF", # Ruff-specific rules
"S", # flake8-bandit
+ "SIM222", # expr-or-true
"SIM910", # dict-get-with-none-default
"SLOT", # flake8-slots
"T10", # flake8-debugger
diff --git a/tests/geometry/test_plane.py b/tests/geometry/test_plane.py
index 6a531f0cf..3a5ad255d 100644
--- a/tests/geometry/test_plane.py
+++ b/tests/geometry/test_plane.py
@@ -99,7 +99,7 @@ class TestHyperplane(BaseTester):
p0 = Vector3.random(shape, device, dtype)
n0 = Vector3.random(shape, device, dtype).normalized()
pl0 = Hyperplane.from_vector(n0, p0)
- assert pl0.normal.shape == shape or (3,)
+ assert pl0.normal.shape == ((*shape, 3) if shape is not None else (3,))
assert pl0.offset.shape == ((*shape,) if shape is not None else ())
def test_serialization(self, device, dtype, tmp_path):
@@ -130,7 +130,7 @@ class TestHyperplane(BaseTester):
v2 = Vector3.random(shape, device, dtype)
# TODO: improve api so that we can accept Vector too
p0 = Hyperplane.through(v0, v1, v2)
- assert p0.normal.shape == shape or (3,)
+ assert p0.normal.shape == ((*shape, 3) if shape is not None else (3,))
assert p0.offset.shape == ((*shape,) if shape is not None else ())
def test_through_orthogonal_equal_length_gradient_5056(self, device, dtype):