Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

test(geometry): clear the default-device override after the RANSAC compile test (#5511)

εŒΊζ’“ηa5e8f00823ce
diff --git a/tests/geometry/test_ransac.py b/tests/geometry/test_ransac.py
index 543094377..3a1249623 100644
--- a/tests/geometry/test_ransac.py
+++ b/tests/geometry/test_ransac.py
@@ -2381,7 +2381,9 @@ class TestRANSACCompiled(BaseTester):
torch.set_default_device("meta")
RANSAC("homography", compile=True, seed=0)(points, points)
finally:
- torch.set_default_device(original)
+ # With no override, ``original`` reads ``cpu``, and ``set_default_device("cpu")`` would leave a
+ # DeviceContext mode on for the rest of the session instead of clearing the override (#5508).
+ torch.set_default_device(None if original.type == "cpu" else original)
assert captured[0][0][-1] == "meta"
assert all(control.device.type == "cpu" for control in captured[0][1][2:])