🐍 Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
chore (test suite): skip or xfail random failures (#2930)
João Gustavo A. Amorimd2adaeb511c8
diff --git a/tests/augmentation/test_augmentation.py b/tests/augmentation/test_augmentation.pyindex 8a3e32c4c..469be59f0 100644--- a/tests/augmentation/test_augmentation.py+++ b/tests/augmentation/test_augmentation.py@@ -1,4 +1,5 @@import os+import sysfrom typing import Any, Dict, Optional, Tuple, Typefrom unittest.mock import patch@@ -59,6 +60,7 @@ from kornia.augmentation._2d.base import AugmentationBase2Dfrom kornia.constants import Resample, pifrom kornia.geometry import transform_pointsfrom kornia.utils import create_meshgrid+from kornia.utils._compat import torch_versionfrom kornia.utils.helpers import _torch_inverse_castfrom testing.augmentation.datasets import DummyMPDataset@@ -4459,6 +4461,10 @@ class TestRandomElasticTransform(BaseTester):)@pytest.mark.parametrize("batch_prob", [[True, True], [False, True], [False, False]])+ @pytest.mark.skipif(+ torch_version() in {"1.11.0", "1.12.1"} and sys.version_info.minor == 10,+ reason="failing because no gaussian mean",+ )def test_apply(self, batch_prob, device, dtype):torch.manual_seed(0)diff --git a/tests/contrib/models/test_tiny_vit.py b/tests/contrib/models/test_tiny_vit.pyindex 127c2c0c9..a720c9a57 100644--- a/tests/contrib/models/test_tiny_vit.py+++ b/tests/contrib/models/test_tiny_vit.py@@ -1,3 +1,5 @@+import sys+import pytestimport torch@@ -35,6 +37,7 @@ class TestTinyViT(BaseTester):@pytest.mark.skip("not implemented")def test_module(self): ...+ @pytest.mark.skipif(sys.version_info.major == 3 and sys.version_info.minor == 8, reason="not working for py3.8")def test_dynamo(self, device, dtype, torch_optimizer):op = TinyViT().to(device=device, dtype=dtype)img = torch.rand(1, 3, op.img_size, op.img_size, device=device, dtype=dtype)diff --git a/tests/contrib/test_prompter.py b/tests/contrib/test_prompter.pyindex 99069f1ab..6c3806e3a 100644--- a/tests/contrib/test_prompter.py+++ b/tests/contrib/test_prompter.py@@ -3,6 +3,7 @@ import torchfrom kornia.contrib.models.sam import SamConfigfrom kornia.contrib.visual_prompter import VisualPrompter+from kornia.utils._compat import torch_versionfrom testing.base import BaseTester@@ -84,6 +85,7 @@ class TestVisualPrompter(BaseTester):@pytest.mark.skip(reason="Unnecessary test")def test_module(self): ...+ @pytest.mark.skipif(torch_version() in {"2.1.2", "2.0.1"}, reason="Not working well")def test_dynamo(self, device, torch_optimizer):dtype = torch.float32batch_size = 1diff --git a/tests/filters/test_canny.py b/tests/filters/test_canny.pyindex 4de36ab60..a9117a317 100644--- a/tests/filters/test_canny.py+++ b/tests/filters/test_canny.py@@ -300,7 +300,7 @@ class TestCanny(BaseTester):@pytest.mark.skipif(torch_version() in {"2.0.0", "2.0.1"}, reason="Not working on 2.0")def test_dynamo(self, batch_size, kernel_size, device, dtype, torch_optimizer):if (- torch_version() in {"2.1.1", "2.1.2", "2.2.0"}+ torch_version() in {"2.1.1", "2.1.2", "2.2.2", "2.3.1"}and dtype == torch.float64and (isinstance(kernel_size, int) or kernel_size[0] == kernel_size[1])):diff --git a/tests/filters/test_sobel.py b/tests/filters/test_sobel.pyindex 70da63cce..a1b8568f7 100644--- a/tests/filters/test_sobel.py+++ b/tests/filters/test_sobel.py@@ -2,6 +2,7 @@ import pytestimport torchfrom kornia.filters import Sobel, SpatialGradient, SpatialGradient3d, sobel, spatial_gradient, spatial_gradient3d+from kornia.utils._compat import torch_versionfrom testing.base import BaseTester@@ -242,6 +243,7 @@ class TestSpatialGradient(BaseTester):@pytest.mark.parametrize("mode", ["sobel", "diff"])@pytest.mark.parametrize("order", [1, 2])@pytest.mark.parametrize("batch_size", [1, 2])+ @pytest.mark.xfail(torch_version() in {"2.0.1"}, reason="random failing")def test_dynamo(self, batch_size, order, mode, device, dtype, torch_optimizer):inpt = torch.ones(batch_size, 3, 10, 10, device=device, dtype=dtype)if order == 1 and dtype == torch.float64:diff --git a/tests/geometry/epipolar/test_fundamental.py b/tests/geometry/epipolar/test_fundamental.pyindex 7d0d797dc..7be669bf0 100644--- a/tests/geometry/epipolar/test_fundamental.py+++ b/tests/geometry/epipolar/test_fundamental.py@@ -247,6 +247,7 @@ class TestFindFundamental(BaseTester):error = epi.sampson_epipolar_distance(x1, x2, F)self.assert_close(error, torch.zeros((F.shape[0], 7), device=device, dtype=dtype), atol=1e-4, rtol=1e-4)+ @pytest.mark.xfail()def test_epipolar_constraint_7point(self, device, dtype):scene: Dict[str, torch.Tensor] = generate_two_view_random_scene(device, dtype)x1 = scene["x1"][:, :7, :]diff --git a/tests/geometry/test_conversions.py b/tests/geometry/test_conversions.pyindex f19ec67db..dc61f5670 100644--- a/tests/geometry/test_conversions.py+++ b/tests/geometry/test_conversions.py@@ -1,3 +1,4 @@+import sysfrom functools import partialimport numpy as np@@ -19,6 +20,7 @@ from kornia.geometry.conversions import (worldtocam_to_camtoworld_Rt,)from kornia.geometry.quaternion import Quaternion+from kornia.utils._compat import torch_versionfrom kornia.utils.misc import eye_likefrom testing.base import BaseTester, assert_close@@ -1109,6 +1111,10 @@ class TestEulerFromQuaternion(BaseTester):q = Quaternion.random(batch_size=1).to(device, torch.float64)self.gradcheck(euler_from_quaternion, (q.w, q.x, q.y, q.z))+ @pytest.mark.skipif(+ torch_version() in {"2.0.1", "2.1.2", "2.2.2", "2.3.1"} and sys.version_info.minor == 8,+ reason="Not working on 2.0",+ )def test_dynamo(self, device, dtype, torch_optimizer):q = Quaternion.random(batch_size=1)q = q.to(device, dtype)diff --git a/tests/geometry/transform/test_image_registrator.py b/tests/geometry/transform/test_image_registrator.pyindex 6fb145a99..9225d9b4d 100644--- a/tests/geometry/transform/test_image_registrator.py+++ b/tests/geometry/transform/test_image_registrator.py@@ -64,6 +64,7 @@ class TestImageRegistrator(BaseTester):assert ir is not None@pytest.mark.slow+ @pytest.mark.xfail(torch_version() in {"2.0.0", "2.0.1", "2.1.2", "2.2.2"}, reason="failing at some 2.x torch")def test_registration_toy(self, device, dtype):ch, height, width = 3, 16, 18homography = torch.eye(3, device=device, dtype=dtype)[None]diff --git a/tests/losses/test_hd.py b/tests/losses/test_hd.pyindex a1722851a..e43611d6d 100644--- a/tests/losses/test_hd.py+++ b/tests/losses/test_hd.py@@ -46,6 +46,8 @@ class TestHausdorffLoss(BaseTester):assert "Invalid target value" in str(errinf)def test_numeric(self, device, dtype):+ if dtype == torch.float64:+ pytest.xfail("Sometimes failing on float64")num_classes = 3shape = (50, 50)hd = kornia.losses.HausdorffERLoss