Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

Correct Sobel test_noncontiguous. Nothing was tested before. (#1018)

Pau Riba34d5a7b4cac0
diff --git a/test/filters/test_sobel.py b/test/filters/test_sobel.py
index 32122ffc0..d18e2b1d5 100644
--- a/test/filters/test_sobel.py
+++ b/test/filters/test_sobel.py
@@ -130,7 +130,10 @@ class TestSpatialGradient:
inp = torch.rand(3, 5, 5, device=device, dtype=dtype).expand(batch_size, -1, -1, -1)
actual = kornia.filters.spatial_gradient(inp)
- assert_allclose(actual, actual)
+
+ assert inp.is_contiguous() is False
+ assert actual.is_contiguous()
+ assert actual.shape == (3, 3, 2, 5, 5)
def test_gradcheck(self, device, dtype):
batch_size, channels, height, width = 1, 1, 3, 4
@@ -296,9 +299,12 @@ class TestSobel:
batch_size = 3
inp = torch.rand(3, 5, 5, device=device, dtype=dtype).expand(batch_size, -1, -1, -1)
- actual = kornia.filters.sobel(inp)
- expected = actual
- assert_allclose(actual, actual)
+ sobel = kornia.filters.Sobel()
+ actual = sobel(inp)
+
+ assert inp.is_contiguous() is False
+ assert actual.is_contiguous()
+ assert actual.shape == (3, 3, 5, 5)
def test_gradcheck_unnorm(self, device, dtype):
if "cuda" in str(device):