π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
adopt torch.testing.assert_close (#1031)
Philip Meierada07a740925
diff --git a/kornia/testing/__init__.py b/kornia/testing/__init__.pyindex 0869e731c..becd68dad 100644--- a/kornia/testing/__init__.py+++ b/kornia/testing/__init__.py@@ -1,14 +1,16 @@"""The testing package contains testing-specific utilities."""+import contextlibimport importlibfrom abc import ABC, abstractmethodfrom copy import deepcopyfrom itertools import product+from typing import Any, Optionalimport torch-__all__ = ['tensor_to_gradcheck_var', 'create_eye_batch', 'xla_is_available']+__all__ = ['tensor_to_gradcheck_var', 'create_eye_batch', 'xla_is_available', 'assert_close']def xla_is_available() -> bool:@@ -128,3 +130,45 @@ def _get_precision_by_name(return tol_valreturn tol_val_default+++try:+ # torch.testing.assert_close is only available for torch>=1.9+ from torch.testing import assert_close as _assert_close+ from torch.testing._core import _get_default_tolerance++ def assert_close(+ actual: torch.Tensor,+ expected: torch.Tensor,+ *,+ rtol: Optional[float] = None,+ atol: Optional[float] = None,+ **kwargs: Any,+ ) -> None:+ if rtol is None and atol is None:+ with contextlib.suppress(Exception):+ rtol, atol = _get_default_tolerance(actual, expected)++ return _assert_close(actual, expected, rtol=rtol, atol=atol, check_stride=False, equal_nan=True, **kwargs)+++except ImportError:+ # Partial backport of torch.testing.assert_close for torch<1.9+ # TODO: remove this branch if kornia relies on torch>=1.9+ from torch.testing import assert_allclose as _assert_allclose++ class UsageError(Exception):+ pass++ def assert_close(+ actual: torch.Tensor,+ expected: torch.Tensor,+ *,+ rtol: Optional[float] = None,+ atol: Optional[float] = None,+ **kwargs: Any,+ ) -> None:+ try:+ return _assert_allclose(actual, expected, rtol=rtol, atol=atol, **kwargs)+ except ValueError as error:+ raise UsageError(str(error)) from errordiff --git a/test/augmentation/test_augmentation.py b/test/augmentation/test_augmentation.pyindex 7ab6f15ef..fac0b4530 100644--- a/test/augmentation/test_augmentation.py+++ b/test/augmentation/test_augmentation.py@@ -4,7 +4,6 @@ import pytestimport torchimport torch.nn as nnfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils@@ -32,7 +31,7 @@ from kornia.augmentation import ()from kornia.augmentation.base import AugmentationBase2Dfrom kornia.constants import pi, Resample-from kornia.testing import BaseTester, default_with_one_parameter_changed+from kornia.testing import assert_close, BaseTester, default_with_one_parameter_changedfrom kornia.utils.helpers import _torch_inverse_cast# TODO same_on_batch tests?@@ -168,7 +167,7 @@ class CommonTests(BaseTester):)assert output.shape[0] == batch_shape[0]assert final_transformation.shape == expected_transformation_shape- assert_allclose(final_transformation, transformation @ test_transform, atol=1e-4, rtol=1e-4)+ assert_close(final_transformation, transformation @ test_transform, atol=1e-4, rtol=1e-4)output, transformation = augmentation((test_input, test_transform), params=generated_params)assert output.shape[0] == batch_shape[0]@@ -190,14 +189,14 @@ class CommonTests(BaseTester):output, final_transformation = augmentation((test_input, test_transform), params=generated_params)assert output.shape[0] == batch_shape[0]assert final_transformation.shape == expected_transformation_shape- assert_allclose(final_transformation, transformation @ test_transform, atol=1e-4, rtol=1e-4)+ assert_close(final_transformation, transformation @ test_transform, atol=1e-4, rtol=1e-4)output, final_transformation = augmentation((test_input, test_transform), params=generated_params, return_transform=True)assert output.shape[0] == batch_shape[0]assert final_transformation.shape == expected_transformation_shape- assert_allclose(final_transformation, transformation @ test_transform, atol=1e-4, rtol=1e-4)+ assert_close(final_transformation, transformation @ test_transform, atol=1e-4, rtol=1e-4)def _test_cardinality_implementation(self, input_shape, expected_output_shape, params):@@ -239,7 +238,7 @@ class CommonTests(BaseTester):# Output should matchassert output.shape == expected_output.shape- assert_allclose(output, expected_output.to(self.device).to(self.dtype), atol=1e-4, rtol=1e-4)+ assert_close(output, expected_output.to(self.device).to(self.dtype), atol=1e-4, rtol=1e-4)def _test_random_p_1_return_transform_implementation(self, input_tensor, expected_output, expected_transformation, params@@ -248,10 +247,10 @@ class CommonTests(BaseTester):output, transformation = augmentation(input_tensor.to(self.device).to(self.dtype))# Output should matchassert output.shape == expected_output.shape- assert_allclose(output, expected_output.to(self.device).to(self.dtype), atol=1e-4, rtol=1e-4)+ assert_close(output, expected_output.to(self.device).to(self.dtype), atol=1e-4, rtol=1e-4)# Transformation should matchassert transformation.shape == expected_transformation.shape- assert_allclose(transformation, expected_transformation.to(self.device).to(self.dtype), atol=1e-4, rtol=1e-4)+ assert_close(transformation, expected_transformation.to(self.device).to(self.dtype), atol=1e-4, rtol=1e-4)def _test_module_implementation(self, params):augmentation = self._create_augmentation_from_params(**params, p=0.5, return_transform=True)@@ -270,8 +269,8 @@ class CommonTests(BaseTester):assert out2.shape == out_sequence.shapeassert transform.shape == transform_sequence.shape- assert_allclose(out2, out_sequence, atol=1e-4, rtol=1e-4)- assert_allclose(transform, transform_sequence, atol=1e-4, rtol=1e-4)+ assert_close(out2, out_sequence, atol=1e-4, rtol=1e-4)+ assert_close(transform, transform_sequence, atol=1e-4, rtol=1e-4)def _test_inverse_coordinate_check_implementation(self, params):torch.manual_seed(42)@@ -299,7 +298,7 @@ class CommonTests(BaseTester):output_values = output[0, :, output_indices[:, 1][value_mask], output_indices[:, 0][value_mask]]input_values = input_tensor[0, :, input_indices[:, 1][value_mask], input_indices[:, 0][value_mask]]- assert_allclose(output_values, input_values, atol=1e-4, rtol=1e-4)+ assert_close(output_values, input_values, atol=1e-4, rtol=1e-4)def _test_gradcheck_implementation(self, params):input_tensor = torch.rand((3, 5, 5), device=self.device, dtype=self.dtype) # 3 x 3@@ -1035,17 +1034,17 @@ class TestRandomVerticalFlip:[[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]], device=device, dtype=dtype) # 3 x 3- assert_allclose(f(input)[0], expected, atol=1e-4, rtol=1e-4)- assert_allclose(f(input)[1], expected_transform, atol=1e-4, rtol=1e-4)- assert_allclose(f1(input)[0], input, atol=1e-4, rtol=1e-4)- assert_allclose(f1(input)[1], identity, atol=1e-4, rtol=1e-4)- assert_allclose(f2(input), expected, atol=1e-4, rtol=1e-4)- assert_allclose(f3(input), input, atol=1e-4, rtol=1e-4)+ assert_close(f(input)[0], expected, atol=1e-4, rtol=1e-4)+ assert_close(f(input)[1], expected_transform, atol=1e-4, rtol=1e-4)+ assert_close(f1(input)[0], input, atol=1e-4, rtol=1e-4)+ assert_close(f1(input)[1], identity, atol=1e-4, rtol=1e-4)+ assert_close(f2(input), expected, atol=1e-4, rtol=1e-4)+ assert_close(f3(input), input, atol=1e-4, rtol=1e-4)- assert_allclose(f.inverse(expected), input, atol=1e-4, rtol=1e-4)- assert_allclose(f1.inverse(input), input, atol=1e-4, rtol=1e-4)- assert_allclose(f2.inverse(expected), input, atol=1e-4, rtol=1e-4)- assert_allclose(f3.inverse(input), input, atol=1e-4, rtol=1e-4)+ assert_close(f.inverse(expected), input, atol=1e-4, rtol=1e-4)+ assert_close(f1.inverse(input), input, atol=1e-4, rtol=1e-4)+ assert_close(f2.inverse(expected), input, atol=1e-4, rtol=1e-4)+ assert_close(f3.inverse(input), input, atol=1e-4, rtol=1e-4)def test_batch_random_vflip(self, device, dtype):@@ -1073,12 +1072,12 @@ class TestRandomVerticalFlip:expected_transform = expected_transform.repeat(5, 1, 1) # 5 x 3 x 3identity = identity.repeat(5, 1, 1) # 5 x 3 x 3- assert_allclose(f(input)[0], expected, atol=1e-4, rtol=1e-4)- assert_allclose(f(input)[1], expected_transform, atol=1e-4, rtol=1e-4)- assert_allclose(f1(input)[0], input, atol=1e-4, rtol=1e-4)- assert_allclose(f1(input)[1], identity, atol=1e-4, rtol=1e-4)- assert_allclose(f.inverse(expected), input, atol=1e-4, rtol=1e-4)- assert_allclose(f1.inverse(input), input, atol=1e-4, rtol=1e-4)+ assert_close(f(input)[0], expected, atol=1e-4, rtol=1e-4)+ assert_close(f(input)[1], expected_transform, atol=1e-4, rtol=1e-4)+ assert_close(f1(input)[0], input, atol=1e-4, rtol=1e-4)+ assert_close(f1(input)[1], identity, atol=1e-4, rtol=1e-4)+ assert_close(f.inverse(expected), input, atol=1e-4, rtol=1e-4)+ assert_close(f1.inverse(input), input, atol=1e-4, rtol=1e-4)def test_same_on_batch(self, device, dtype):f = RandomVerticalFlip(p=0.5, same_on_batch=True)@@ -1104,10 +1103,10 @@ class TestRandomVerticalFlip:expected_transform_1 = expected_transform @ expected_transform- assert_allclose(f(input)[0], input, atol=1e-4, rtol=1e-4)- assert_allclose(f(input)[1], expected_transform_1, atol=1e-4, rtol=1e-4)- assert_allclose(f1(input)[0], input, atol=1e-4, rtol=1e-4)- assert_allclose(f1(input)[1], expected_transform, atol=1e-4, rtol=1e-4)+ assert_close(f(input)[0], input, atol=1e-4, rtol=1e-4)+ assert_close(f(input)[1], expected_transform_1, atol=1e-4, rtol=1e-4)+ assert_close(f1(input)[0], input, atol=1e-4, rtol=1e-4)+ assert_close(f1(input)[1], expected_transform, atol=1e-4, rtol=1e-4)def test_random_vflip_coord_check(self, device, dtype):@@ -1182,9 +1181,9 @@ class TestColorJitter:expected_transform = torch.eye(3, device=device, dtype=dtype).unsqueeze(0) # 3 x 3- assert_allclose(f(input), expected, atol=1e-4, rtol=1e-5)- assert_allclose(f1(input)[0], expected, atol=1e-4, rtol=1e-5)- assert_allclose(f1(input)[1], expected_transform, atol=1e-4, rtol=1e-4)+ assert_close(f(input), expected, atol=1e-4, rtol=1e-5)+ assert_close(f1(input)[0], expected, atol=1e-4, rtol=1e-5)+ assert_close(f1(input)[1], expected_transform, atol=1e-4, rtol=1e-4)def test_color_jitter_batch(self, device, dtype):f = ColorJitter()@@ -1195,9 +1194,9 @@ class TestColorJitter:expected_transform = torch.eye(3, device=device, dtype=dtype).unsqueeze(0).expand((2, 3, 3)) # 2 x 3 x 3- assert_allclose(f(input), expected, atol=1e-4, rtol=1e-5)- assert_allclose(f1(input)[0], expected, atol=1e-4, rtol=1e-5)- assert_allclose(f1(input)[1], expected_transform, atol=1e-4, rtol=1e-4)+ assert_close(f(input), expected, atol=1e-4, rtol=1e-5)+ assert_close(f1(input)[0], expected, atol=1e-4, rtol=1e-5)+ assert_close(f1(input)[1], expected_transform, atol=1e-4, rtol=1e-4)def test_same_on_batch(self, device, dtype):f = ColorJitter(brightness=0.5, contrast=0.5, saturation=0.5, hue=0.1, same_on_batch=True)@@ -1234,7 +1233,7 @@ class TestColorJitter:expected = self._get_expected_brightness(device, dtype)- assert_allclose(f(input), expected, atol=1e-4, rtol=1e-4)+ assert_close(f(input), expected, atol=1e-4, rtol=1e-4)def test_random_brightness_tuple(self, device, dtype):torch.manual_seed(42)@@ -1247,7 +1246,7 @@ class TestColorJitter:expected = self._get_expected_brightness(device, dtype)- assert_allclose(f(input), expected, atol=1e-4, rtol=1e-4)+ assert_close(f(input), expected, atol=1e-4, rtol=1e-4)def _get_expected_contrast(self, device, dtype):return torch.tensor(@@ -1278,7 +1277,7 @@ class TestColorJitter:expected = self._get_expected_contrast(device, dtype)- assert_allclose(f(input), expected, atol=1e-4, rtol=1e-5)+ assert_close(f(input), expected, atol=1e-4, rtol=1e-5)def test_random_contrast_list(self, device, dtype):torch.manual_seed(42)@@ -1291,7 +1290,7 @@ class TestColorJitter:expected = self._get_expected_contrast(device, dtype)- assert_allclose(f(input), expected, atol=1e-4, rtol=1e-5)+ assert_close(f(input), expected, atol=1e-4, rtol=1e-5)def _get_expected_saturation(self, device, dtype):return torch.tensor(@@ -1329,7 +1328,7 @@ class TestColorJitter:input = input.repeat(2, 1, 1, 1) # 2 x 3 x 3expected = self._get_expected_saturation(device, dtype)- assert_allclose(f(input), expected, atol=1e-4, rtol=1e-4)+ assert_close(f(input), expected, atol=1e-4, rtol=1e-4)def test_random_saturation_tensor(self, device, dtype):torch.manual_seed(42)@@ -1350,7 +1349,7 @@ class TestColorJitter:expected = self._get_expected_saturation(device, dtype)- assert_allclose(f(input), expected, atol=1e-4, rtol=1e-4)+ assert_close(f(input), expected, atol=1e-4, rtol=1e-4)def test_random_saturation_tuple(self, device, dtype):torch.manual_seed(42)@@ -1371,7 +1370,7 @@ class TestColorJitter:expected = self._get_expected_saturation(device, dtype)- assert_allclose(f(input), expected, atol=1e-4, rtol=1e-4)+ assert_close(f(input), expected, atol=1e-4, rtol=1e-4)def _get_expected_hue(self, device, dtype):return torch.tensor(@@ -1410,7 +1409,7 @@ class TestColorJitter:expected = self._get_expected_hue(device, dtype)- assert_allclose(f(input), expected, atol=1e-4, rtol=1e-4)+ assert_close(f(input), expected, atol=1e-4, rtol=1e-4)def test_random_hue_list(self, device, dtype):torch.manual_seed(42)@@ -1431,7 +1430,7 @@ class TestColorJitter:expected = self._get_expected_hue(device, dtype)- assert_allclose(f(input), expected, atol=1e-4, rtol=1e-4)+ assert_close(f(input), expected, atol=1e-4, rtol=1e-4)def test_random_hue_list_batch(self, device, dtype):torch.manual_seed(42)@@ -1452,7 +1451,7 @@ class TestColorJitter:expected = self._get_expected_hue(device, dtype)- assert_allclose(f(input), expected, atol=1e-4, rtol=1e-4)+ assert_close(f(input), expected, atol=1e-4, rtol=1e-4)def test_sequential(self, device, dtype):@@ -1464,8 +1463,8 @@ class TestColorJitter:expected_transform = torch.eye(3, device=device, dtype=dtype).unsqueeze(0) # 3 x 3- assert_allclose(f(input)[0], expected, atol=1e-4, rtol=1e-5)- assert_allclose(f(input)[1], expected_transform, atol=1e-4, rtol=1e-5)+ assert_close(f(input)[0], expected, atol=1e-4, rtol=1e-5)+ assert_close(f(input)[1], expected_transform, atol=1e-4, rtol=1e-5)def test_color_jitter_batch_sequential(self, device, dtype):f = nn.Sequential(ColorJitter(return_transform=True), ColorJitter(return_transform=True))@@ -1475,9 +1474,9 @@ class TestColorJitter:expected_transform = torch.eye(3, device=device, dtype=dtype).unsqueeze(0).expand((2, 3, 3)) # 2 x 3 x 3- assert_allclose(f(input)[0], expected, atol=1e-4, rtol=1e-5)- assert_allclose(f(input)[0], expected, atol=1e-4, rtol=1e-5)- assert_allclose(f(input)[1], expected_transform, atol=1e-4, rtol=1e-5)+ assert_close(f(input)[0], expected, atol=1e-4, rtol=1e-5)+ assert_close(f(input)[0], expected, atol=1e-4, rtol=1e-5)+ assert_close(f(input)[1], expected_transform, atol=1e-4, rtol=1e-5)def test_gradcheck(self, device, dtype):input = torch.rand((3, 5, 5), device=device, dtype=dtype).unsqueeze(0) # 3 x 3@@ -1535,7 +1534,7 @@ class TestRectangleRandomErasing:img = torch.ones(batch_size, channels, height, width)expected = RandomErasing(1.0, (0.2, 0.4), (0.3, 0.5))(img)actual = op_script(img)- assert_allclose(actual, expected, atol=1e-4, rtol=1e-4)+ assert_close(actual, expected, atol=1e-4, rtol=1e-4)class TestRandomGrayscale:@@ -1556,7 +1555,7 @@ class TestRandomGrayscale:expected_transform = torch.eye(3, device=device, dtype=dtype).unsqueeze(0) # 3 x 3- assert_allclose(f(input)[1], expected_transform, atol=1e-4, rtol=1e-4)+ assert_close(f(input)[1], expected_transform, atol=1e-4, rtol=1e-4)def test_same_on_batch(self, device, dtype):f = RandomGrayscale(p=0.5, same_on_batch=True)@@ -1627,7 +1626,7 @@ class TestRandomGrayscale:)img_gray = kornia.augmentation.RandomGrayscale(p=1.0)(data)- assert_allclose(img_gray, expected, atol=1e-4, rtol=1e-4)+ assert_close(img_gray, expected, atol=1e-4, rtol=1e-4)def test_opencv_false(self, device, dtype):data = torch.tensor(@@ -1663,7 +1662,7 @@ class TestRandomGrayscale:expected = dataimg_gray = kornia.augmentation.RandomGrayscale(p=0.0)(data)- assert_allclose(img_gray, expected, atol=1e-4, rtol=1e-4)+ assert_close(img_gray, expected, atol=1e-4, rtol=1e-4)def test_opencv_true_batch(self, device, dtype):data = torch.tensor(@@ -1726,7 +1725,7 @@ class TestRandomGrayscale:expected = expected.unsqueeze(0).repeat(4, 1, 1, 1)img_gray = kornia.augmentation.RandomGrayscale(p=1.0)(data)- assert_allclose(img_gray, expected, atol=1e-4, rtol=1e-4)+ assert_close(img_gray, expected, atol=1e-4, rtol=1e-4)def test_opencv_false_batch(self, device, dtype):data = torch.tensor(@@ -1761,7 +1760,7 @@ class TestRandomGrayscale:expected = dataimg_gray = kornia.augmentation.RandomGrayscale(p=0.0)(data)- assert_allclose(img_gray, expected, atol=1e-4, rtol=1e-4)+ assert_close(img_gray, expected, atol=1e-4, rtol=1e-4)def test_random_grayscale_sequential_batch(self, device, dtype):f = nn.Sequential(RandomGrayscale(p=0.0, return_transform=True), RandomGrayscale(p=0.0, return_transform=True))@@ -1772,8 +1771,8 @@ class TestRandomGrayscale:expected_transform = torch.eye(3, device=device, dtype=dtype).unsqueeze(0).expand((2, 3, 3)) # 2 x 3 x 3expected_transform = expected_transform.to(device)- assert_allclose(f(input)[0], expected, atol=1e-4, rtol=1e-4)- assert_allclose(f(input)[1], expected_transform, atol=1e-4, rtol=1e-4)+ assert_close(f(input)[0], expected, atol=1e-4, rtol=1e-4)+ assert_close(f(input)[1], expected_transform, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):input = torch.rand((3, 5, 5), device=device, dtype=dtype) # 3 x 3@@ -1822,7 +1821,7 @@ class TestCenterCrop:op2 = CenterCrop(size=(2, 2), cropping_mode='slice')- assert_allclose(out, op2(img, op1._params))+ assert_close(out, op2(img, op1._params))def test_gradcheck(self, device, dtype):input = torch.rand(1, 2, 3, 4, device=device, dtype=dtype)@@ -1895,9 +1894,9 @@ class TestRandomRotation:) # 1 x 4 x 4out, mat = f(input)- assert_allclose(out, expected, rtol=1e-6, atol=1e-4)- assert_allclose(mat, expected_transform, rtol=1e-6, atol=1e-4)- assert_allclose(f1(input), expected_2, rtol=1e-6, atol=1e-4)+ assert_close(out, expected, rtol=1e-6, atol=1e-4)+ assert_close(mat, expected_transform, rtol=1e-6, atol=1e-4)+ assert_close(f1(input), expected_2, rtol=1e-6, atol=1e-4)def test_batch_random_rotation(self, device, dtype):@@ -1946,8 +1945,8 @@ class TestRandomRotation:input = input.repeat(2, 1, 1, 1) # 5 x 3 x 3 x 3out, mat = f(input)- assert_allclose(out, expected, rtol=1e-4, atol=1e-4)- assert_allclose(mat, expected_transform, rtol=1e-4, atol=1e-4)+ assert_close(out, expected, rtol=1e-4, atol=1e-4)+ assert_close(mat, expected_transform, rtol=1e-4, atol=1e-4)def test_same_on_batch(self, device, dtype):f = RandomRotation(degrees=40, same_on_batch=True)@@ -2002,9 +2001,9 @@ class TestRandomRotation:out, mat = f(input)_, mat_2 = f1(input)- assert_allclose(out, expected, rtol=1e-4, atol=1e-4)- assert_allclose(mat, expected_transform, rtol=1e-4, atol=1e-4)- assert_allclose(mat_2, expected_transform_2, rtol=1e-4, atol=1e-4)+ assert_close(out, expected, rtol=1e-4, atol=1e-4)+ assert_close(mat, expected_transform, rtol=1e-4, atol=1e-4)+ assert_close(mat_2, expected_transform_2, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device, dtype):@@ -2037,14 +2036,14 @@ class TestRandomCrop:torch.manual_seed(0)out2 = rc(inp.squeeze())- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)- assert_allclose(out2, expected, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(out2, expected, atol=1e-4, rtol=1e-4)torch.manual_seed(0)inversed = torch.tensor([[[[0.0, 0.0, 0.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]]]], device=device, dtype=dtype)aug = RandomCrop(size=(2, 3), padding=None, align_corners=True, p=1.0, cropping_mode="resample")out = aug(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)- assert_allclose(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)def test_no_padding_batch(self, device, dtype):torch.manual_seed(42)@@ -2057,7 +2056,7 @@ class TestRandomCrop:)rc = RandomCrop(size=(2, 3), padding=None, align_corners=True, p=1.0)out = rc(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)torch.manual_seed(42)inversed = torch.tensor(@@ -2070,8 +2069,8 @@ class TestRandomCrop:)aug = RandomCrop(size=(2, 3), padding=None, align_corners=True, p=1.0, cropping_mode="resample")out = aug(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)- assert_allclose(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)def test_same_on_batch(self, device, dtype):f = RandomCrop(size=(2, 3), padding=1, same_on_batch=True, align_corners=True, p=1.0)@@ -2089,16 +2088,16 @@ class TestRandomCrop:torch.manual_seed(42)out2 = rc(inp.squeeze())- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)- assert_allclose(out2, expected, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(out2, expected, atol=1e-4, rtol=1e-4)torch.manual_seed(42)inversed = torch.tensor([[[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 7.0, 8.0]]]], device=device, dtype=dtype)aug = RandomCrop(size=(2, 3), padding=1, padding_mode='reflect', align_corners=True, p=1.0, cropping_mode="resample")out = aug(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)- assert_allclose(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)def test_padding_batch_1(self, device, dtype):torch.manual_seed(42)@@ -2112,7 +2111,7 @@ class TestRandomCrop:rc = RandomCrop(size=(2, 3), padding=1, align_corners=True, p=1.0)out = rc(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)torch.manual_seed(42)inversed = torch.tensor(@@ -2125,8 +2124,8 @@ class TestRandomCrop:)aug = RandomCrop(size=(2, 3), padding=1, align_corners=True, p=1.0, cropping_mode="resample")out = aug(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)- assert_allclose(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)def test_padding_batch_2(self, device, dtype):torch.manual_seed(42)@@ -2140,7 +2139,7 @@ class TestRandomCrop:rc = RandomCrop(size=(2, 3), padding=(0, 1), fill=10, align_corners=True, p=1.0)out = rc(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)torch.manual_seed(42)inversed = torch.tensor([@@ -2152,8 +2151,8 @@ class TestRandomCrop:)aug = RandomCrop(size=(2, 3), padding=(0, 1), fill=10, align_corners=True, p=1.0, cropping_mode="resample")out = aug(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)- assert_allclose(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)def test_padding_batch_3(self, device, dtype):torch.manual_seed(0)@@ -2167,7 +2166,7 @@ class TestRandomCrop:rc = RandomCrop(size=(2, 3), padding=(0, 1, 2, 3), fill=8, align_corners=True, p=1.0)out = rc(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)torch.manual_seed(0)inversed = torch.tensor(@@ -2180,8 +2179,8 @@ class TestRandomCrop:)aug = RandomCrop(size=(2, 3), padding=(0, 1, 2, 3), fill=8, align_corners=True, p=1.0, cropping_mode="resample")out = aug(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)- assert_allclose(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)def test_padding_no_forward(self, device, dtype):torch.manual_seed(0)@@ -2191,20 +2190,20 @@ class TestRandomCrop:rc = RandomCrop(size=(2, 3), padding=(0, 1, 2, 3), fill=9, align_corners=True, p=0.0)out = rc(inp)- assert_allclose(out, inp, atol=1e-4, rtol=1e-4)+ assert_close(out, inp, atol=1e-4, rtol=1e-4)out = rc((inp, trans))- assert_allclose(out[0], inp, atol=1e-4, rtol=1e-4)- assert_allclose(out[1], trans, atol=1e-4, rtol=1e-4)+ assert_close(out[0], inp, atol=1e-4, rtol=1e-4)+ assert_close(out[1], trans, atol=1e-4, rtol=1e-4)# with return transformrc = RandomCrop(size=(2, 3), padding=(0, 1, 2, 3), fill=9, align_corners=True, p=0.0, return_transform=True)out = rc(inp)- assert_allclose(out[0], inp, atol=1e-4, rtol=1e-4)+ assert_close(out[0], inp, atol=1e-4, rtol=1e-4)out = rc((inp, trans))- assert_allclose(out[0], inp, atol=1e-4, rtol=1e-4)- assert_allclose(out[1], trans, atol=1e-4, rtol=1e-4)+ assert_close(out[0], inp, atol=1e-4, rtol=1e-4)+ assert_close(out[1], trans, atol=1e-4, rtol=1e-4)def test_pad_if_needed(self, device, dtype):torch.manual_seed(0)@@ -2216,14 +2215,14 @@ class TestRandomCrop:rc = RandomCrop(size=(2, 3), pad_if_needed=True, fill=9, align_corners=True, p=1.0)out = rc(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)torch.manual_seed(0)inversed = torch.tensor([[[[0.0, 1.0, 2.0]]], [[[0.0, 1.0, 2.0]]]], device=device, dtype=dtype)aug = RandomCrop(size=(2, 3), pad_if_needed=True, fill=9, align_corners=True, p=1.0, cropping_mode="resample")out = aug(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)- assert_allclose(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)def test_crop_modes(self, device, dtype):torch.manual_seed(0)@@ -2234,7 +2233,7 @@ class TestRandomCrop:op2 = RandomCrop(size=(2, 2), cropping_mode='slice')- assert_allclose(out, op2(img, op1._params))+ assert_close(out, op2(img, op1._params))def test_gradcheck(self, device, dtype):torch.manual_seed(0) # for random reproductibility@@ -2251,7 +2250,7 @@ class TestRandomCrop:actual = op_script(img)expected = kornia.center_crop3d(img)- assert_allclose(actual, expected, atol=1e-4, rtol=1e-4)+ assert_close(actual, expected, atol=1e-4, rtol=1e-4)@pytest.mark.skip("Need to fix Union type")def test_jit_trace(self, device, dtype):@@ -2269,7 +2268,7 @@ class TestRandomCrop:# 3. Evaluateactual = op_trace(img)expected = op(img)- assert_allclose(actual, expected, atol=1e-4, rtol=1e-4)+ assert_close(actual, expected, atol=1e-4, rtol=1e-4)class TestRandomResizedCrop:@@ -2293,13 +2292,13 @@ class TestRandomResizedCrop:rrc = RandomResizedCrop(size=(2, 3), scale=(1.0, 1.0), ratio=(1.0, 1.0))# It will crop a size of (2, 3) from the aspect ratio implementation of torchout = rrc(inp)- assert_allclose(out, expected, rtol=1e-4, atol=1e-4)+ assert_close(out, expected, rtol=1e-4, atol=1e-4)torch.manual_seed(0)aug = RandomResizedCrop(size=(2, 3), scale=(1.0, 1.0), ratio=(1.0, 1.0), cropping_mode="resample")out = aug(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)- assert_allclose(aug.inverse(out), inp[None], atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(aug.inverse(out), inp[None], atol=1e-4, rtol=1e-4)def test_same_on_batch(self, device, dtype):f = RandomResizedCrop(size=(2, 3), scale=(1.0, 1.0), ratio=(1.0, 1.0), same_on_batch=True)@@ -2330,14 +2329,14 @@ class TestRandomResizedCrop:rrc = RandomResizedCrop(size=(3, 3), scale=(3.0, 3.0), ratio=(2.0, 2.0))# It will crop a size of (3, 3) from the aspect ratio implementation of torchout = rrc(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)torch.manual_seed(0)inversed = torch.tensor([[[[0.0, 1.0, 2.0], [0.0, 4.0, 5.0], [0.0, 7.0, 8.0]]]], device=device, dtype=dtype)aug = RandomResizedCrop(size=(3, 3), scale=(3.0, 3.0), ratio=(2.0, 2.0), cropping_mode="resample")out = aug(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)- assert_allclose(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)def test_crop_size_greater_than_input(self, device, dtype):# This is included in doctest@@ -2363,14 +2362,14 @@ class TestRandomResizedCrop:# It will crop a size of (3, 3) from the aspect ratio implementation of torchout = rrc(inp)assert out.shape == torch.Size([1, 1, 4, 4])- assert_allclose(out, exp, atol=1e-4, rtol=1e-4)+ assert_close(out, exp, atol=1e-4, rtol=1e-4)torch.manual_seed(0)inversed = torch.tensor([[[[0.0, 1.0, 2.0], [0.0, 4.0, 5.0], [0.0, 7.0, 8.0]]]], device=device, dtype=dtype)aug = RandomResizedCrop(size=(4, 4), scale=(3.0, 3.0), ratio=(2.0, 2.0), cropping_mode="resample")out = aug(inp)- assert_allclose(out, exp, atol=1e-4, rtol=1e-4)- assert_allclose(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)+ assert_close(out, exp, atol=1e-4, rtol=1e-4)+ assert_close(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)def test_crop_scale_ratio_batch(self, device, dtype):torch.manual_seed(0)@@ -2390,7 +2389,7 @@ class TestRandomResizedCrop:rrc = RandomResizedCrop(size=(3, 3), scale=(3.0, 3.0), ratio=(2.0, 2.0))# It will crop a size of (2, 2) from the aspect ratio implementation of torchout = rrc(inp)- assert_allclose(out, expected, rtol=1e-4, atol=1e-4)+ assert_close(out, expected, rtol=1e-4, atol=1e-4)torch.manual_seed(0)inversed = torch.tensor(@@ -2403,8 +2402,8 @@ class TestRandomResizedCrop:)aug = RandomResizedCrop(size=(3, 3), scale=(3.0, 3.0), ratio=(2.0, 2.0), cropping_mode="resample")out = aug(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)- assert_allclose(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(aug.inverse(out), inversed, atol=1e-4, rtol=1e-4)def test_crop_modes(self, device, dtype):torch.manual_seed(0)@@ -2415,7 +2414,7 @@ class TestRandomResizedCrop:op2 = RandomResizedCrop(size=(4, 4), cropping_mode='slice')- assert_allclose(out, op2(img, op1._params))+ assert_close(out, op2(img, op1._params))def test_gradcheck(self, device, dtype):torch.manual_seed(0) # for random reproductibility@@ -2472,12 +2471,12 @@ class TestRandomEqualize:expected = self.build_input(channels, height, width, bs=1, row=row_expected, device=device, dtype=dtype)identity = kornia.eye_like(3, expected) # 3 x 3- assert_allclose(f(inputs)[0], expected, rtol=1e-4, atol=1e-4)- assert_allclose(f(inputs)[1], identity, rtol=1e-4, atol=1e-4)- assert_allclose(f1(inputs)[0], inputs, rtol=1e-4, atol=1e-4)- assert_allclose(f1(inputs)[1], identity, rtol=1e-4, atol=1e-4)- assert_allclose(f2(inputs), expected, rtol=1e-4, atol=1e-4)- assert_allclose(f3(inputs), inputs, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs)[0], expected, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs)[1], identity, rtol=1e-4, atol=1e-4)+ assert_close(f1(inputs)[0], inputs, rtol=1e-4, atol=1e-4)+ assert_close(f1(inputs)[1], identity, rtol=1e-4, atol=1e-4)+ assert_close(f2(inputs), expected, rtol=1e-4, atol=1e-4)+ assert_close(f3(inputs), inputs, rtol=1e-4, atol=1e-4)def test_batch_random_equalize(self, device, dtype):f = RandomEqualize(p=1.0, return_transform=True)@@ -2517,12 +2516,12 @@ class TestRandomEqualize:identity = kornia.eye_like(3, expected) # 2 x 3 x 3- assert_allclose(f(inputs)[0], expected, rtol=1e-4, atol=1e-4)- assert_allclose(f(inputs)[1], identity, rtol=1e-4, atol=1e-4)- assert_allclose(f1(inputs)[0], inputs, rtol=1e-4, atol=1e-4)- assert_allclose(f1(inputs)[1], identity, rtol=1e-4, atol=1e-4)- assert_allclose(f2(inputs), expected, rtol=1e-4, atol=1e-4)- assert_allclose(f3(inputs), inputs, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs)[0], expected, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs)[1], identity, rtol=1e-4, atol=1e-4)+ assert_close(f1(inputs)[0], inputs, rtol=1e-4, atol=1e-4)+ assert_close(f1(inputs)[1], identity, rtol=1e-4, atol=1e-4)+ assert_close(f2(inputs), expected, rtol=1e-4, atol=1e-4)+ assert_close(f3(inputs), inputs, rtol=1e-4, atol=1e-4)def test_same_on_batch(self, device, dtype):f = RandomEqualize(p=0.5, same_on_batch=True)@@ -2565,7 +2564,7 @@ class TestGaussianBlur:class TestRandomInvert:def test_smoke(self, device, dtype):img = torch.ones(1, 3, 4, 5, device=device, dtype=dtype)- assert_allclose(RandomInvert(p=1.0)(img), torch.zeros_like(img))+ assert_close(RandomInvert(p=1.0)(img), torch.zeros_like(img))class TestRandomChannelShuffle:@@ -2581,7 +2580,7 @@ class TestRandomChannelShuffle:aug = RandomChannelShuffle(p=1.0)out = aug(img)- assert_allclose(out, out_expected)+ assert_close(out, out_expected)class TestRandomGaussianNoise:@@ -2616,12 +2615,12 @@ class TestNormalize:identity = kornia.eye_like(3, expected)- assert_allclose(f(inputs)[0], expected, rtol=1e-4, atol=1e-4)- assert_allclose(f(inputs)[1], identity, rtol=1e-4, atol=1e-4)- assert_allclose(f1(inputs)[0], inputs, rtol=1e-4, atol=1e-4)- assert_allclose(f1(inputs)[1], identity, rtol=1e-4, atol=1e-4)- assert_allclose(f2(inputs), expected, rtol=1e-4, atol=1e-4)- assert_allclose(f3(inputs), inputs, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs)[0], expected, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs)[1], identity, rtol=1e-4, atol=1e-4)+ assert_close(f1(inputs)[0], inputs, rtol=1e-4, atol=1e-4)+ assert_close(f1(inputs)[1], identity, rtol=1e-4, atol=1e-4)+ assert_close(f2(inputs), expected, rtol=1e-4, atol=1e-4)+ assert_close(f3(inputs), inputs, rtol=1e-4, atol=1e-4)def test_batch_random_normalize(self, device, dtype):f = Normalize(mean=torch.tensor([1.0]), std=torch.tensor([0.5]), p=1.0, return_transform=True)@@ -2635,12 +2634,12 @@ class TestNormalize:identity = kornia.eye_like(3, expected)- assert_allclose(f(inputs)[0], expected, rtol=1e-4, atol=1e-4)- assert_allclose(f(inputs)[1], identity, rtol=1e-4, atol=1e-4)- assert_allclose(f1(inputs)[0], inputs, rtol=1e-4, atol=1e-4)- assert_allclose(f1(inputs)[1], identity, rtol=1e-4, atol=1e-4)- assert_allclose(f2(inputs), expected, rtol=1e-4, atol=1e-4)- assert_allclose(f3(inputs), inputs, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs)[0], expected, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs)[1], identity, rtol=1e-4, atol=1e-4)+ assert_close(f1(inputs)[0], inputs, rtol=1e-4, atol=1e-4)+ assert_close(f1(inputs)[1], identity, rtol=1e-4, atol=1e-4)+ assert_close(f2(inputs), expected, rtol=1e-4, atol=1e-4)+ assert_close(f3(inputs), inputs, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device, dtype):@@ -2677,12 +2676,12 @@ class TestDenormalize:identity = kornia.eye_like(3, expected)- assert_allclose(f(inputs)[0], expected, rtol=1e-4, atol=1e-4)- assert_allclose(f(inputs)[1], identity, rtol=1e-4, atol=1e-4)- assert_allclose(f1(inputs)[0], inputs, rtol=1e-4, atol=1e-4)- assert_allclose(f1(inputs)[1], identity, rtol=1e-4, atol=1e-4)- assert_allclose(f2(inputs), expected, rtol=1e-4, atol=1e-4)- assert_allclose(f3(inputs), inputs, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs)[0], expected, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs)[1], identity, rtol=1e-4, atol=1e-4)+ assert_close(f1(inputs)[0], inputs, rtol=1e-4, atol=1e-4)+ assert_close(f1(inputs)[1], identity, rtol=1e-4, atol=1e-4)+ assert_close(f2(inputs), expected, rtol=1e-4, atol=1e-4)+ assert_close(f3(inputs), inputs, rtol=1e-4, atol=1e-4)def test_batch_random_denormalize(self, device, dtype):f = Denormalize(mean=torch.tensor([1.0]), std=torch.tensor([0.5]), p=1.0, return_transform=True)@@ -2696,12 +2695,12 @@ class TestDenormalize:identity = kornia.eye_like(3, expected)- assert_allclose(f(inputs)[0], expected, rtol=1e-4, atol=1e-4)- assert_allclose(f(inputs)[1], identity, rtol=1e-4, atol=1e-4)- assert_allclose(f1(inputs)[0], inputs, rtol=1e-4, atol=1e-4)- assert_allclose(f1(inputs)[1], identity, rtol=1e-4, atol=1e-4)- assert_allclose(f2(inputs), expected, rtol=1e-4, atol=1e-4)- assert_allclose(f3(inputs), inputs, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs)[0], expected, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs)[1], identity, rtol=1e-4, atol=1e-4)+ assert_close(f1(inputs)[0], inputs, rtol=1e-4, atol=1e-4)+ assert_close(f1(inputs)[1], identity, rtol=1e-4, atol=1e-4)+ assert_close(f2(inputs), expected, rtol=1e-4, atol=1e-4)+ assert_close(f3(inputs), inputs, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device, dtype):diff --git a/test/augmentation/test_augmentation_3d.py b/test/augmentation/test_augmentation_3d.pyindex fb739b4bb..e7c180b2c 100644--- a/test/augmentation/test_augmentation_3d.py+++ b/test/augmentation/test_augmentation_3d.py@@ -4,7 +4,6 @@ import pytestimport torchimport torch.nn as nnfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils@@ -16,6 +15,7 @@ from kornia.augmentation import (RandomRotation3D,RandomVerticalFlip3D,)+from kornia.testing import assert_closeclass TestRandomHorizontalFlip3D:@@ -192,12 +192,12 @@ class TestRandomVerticalFlip3D:dtype=dtype,) # 1 x 4 x 4- assert_allclose(f(input)[0], expected)- assert_allclose(f(input)[1], expected_transform)- assert_allclose(f1(input)[0], input)- assert_allclose(f1(input)[1], identity)- assert_allclose(f2(input), expected)- assert_allclose(f3(input), input)+ assert_close(f(input)[0], expected)+ assert_close(f(input)[1], expected_transform)+ assert_close(f1(input)[0], input)+ assert_close(f1(input)[1], identity)+ assert_close(f2(input), expected)+ assert_close(f3(input), input)def test_batch_random_vflip(self, device):@@ -225,10 +225,10 @@ class TestRandomVerticalFlip3D:expected_transform = expected_transform.repeat(5, 1, 1) # 5 x 4 x 4identity = identity.repeat(5, 1, 1) # 5 x 4 x 4- assert_allclose(f(input)[0], expected)- assert_allclose(f(input)[1], expected_transform)- assert_allclose(f1(input)[0], input)- assert_allclose(f1(input)[1], identity)+ assert_close(f(input)[0], expected)+ assert_close(f(input)[1], expected_transform)+ assert_close(f1(input)[0], input)+ assert_close(f1(input)[1], identity)def test_same_on_batch(self, device):f = RandomVerticalFlip3D(p=0.5, same_on_batch=True)@@ -253,10 +253,10 @@ class TestRandomVerticalFlip3D:expected_transform_1 = expected_transform @ expected_transform- assert_allclose(f(input)[0], input)- assert_allclose(f(input)[1], expected_transform_1)- assert_allclose(f1(input)[0], input)- assert_allclose(f1(input)[1], expected_transform)+ assert_close(f(input)[0], input)+ assert_close(f(input)[1], expected_transform_1)+ assert_close(f1(input)[0], input)+ assert_close(f1(input)[1], expected_transform)def test_gradcheck(self, device):input = torch.rand((1, 3, 3)).to(device) # 4 x 4@@ -319,12 +319,12 @@ class TestRandomDepthicalFlip3D:dtype=dtype,) # 4 x 4- assert_allclose(f(input)[0], expected)- assert_allclose(f(input)[1], expected_transform)- assert_allclose(f1(input)[0], input)- assert_allclose(f1(input)[1], identity)- assert_allclose(f2(input), expected)- assert_allclose(f3(input), input)+ assert_close(f(input)[0], expected)+ assert_close(f(input)[1], expected_transform)+ assert_close(f1(input)[0], input)+ assert_close(f1(input)[1], identity)+ assert_close(f2(input), expected)+ assert_close(f3(input), input)def test_batch_random_dflip(self, device):@@ -363,10 +363,10 @@ class TestRandomDepthicalFlip3D:expected_transform = expected_transform.repeat(5, 1, 1) # 5 x 4 x 4identity = identity.repeat(5, 1, 1) # 5 x 4 x 4- assert_allclose(f(input)[0], expected)- assert_allclose(f(input)[1], expected_transform)- assert_allclose(f1(input)[0], input)- assert_allclose(f1(input)[1], identity)+ assert_close(f(input)[0], expected)+ assert_close(f(input)[1], expected_transform)+ assert_close(f1(input)[0], input)+ assert_close(f1(input)[1], identity)def test_same_on_batch(self, device):f = RandomDepthicalFlip3D(p=0.5, same_on_batch=True)@@ -400,10 +400,10 @@ class TestRandomDepthicalFlip3D:expected_transform_1 = expected_transform @ expected_transform- assert_allclose(f(input)[0], input)- assert_allclose(f(input)[1], expected_transform_1)- assert_allclose(f1(input)[0], input)- assert_allclose(f1(input)[1], expected_transform)+ assert_close(f(input)[0], input)+ assert_close(f(input)[1], expected_transform_1)+ assert_close(f1(input)[0], input)+ assert_close(f1(input)[1], expected_transform)def test_gradcheck(self, device):input = torch.rand((1, 3, 3)).to(device) # 4 x 4@@ -488,11 +488,11 @@ class TestRandomRotation3D:)out, mat = f(input)- assert_allclose(out, expected, rtol=1e-6, atol=1e-4)- assert_allclose(mat, expected_transform, rtol=1e-6, atol=1e-4)+ assert_close(out, expected, rtol=1e-6, atol=1e-4)+ assert_close(mat, expected_transform, rtol=1e-6, atol=1e-4)torch.manual_seed(0) # for random reproductibility- assert_allclose(f1(input), expected, rtol=1e-6, atol=1e-4)+ assert_close(f1(input), expected, rtol=1e-6, atol=1e-4)def test_batch_random_rotation(self, device, dtype):@@ -585,8 +585,8 @@ class TestRandomRotation3D:input = input.repeat(2, 1, 1, 1, 1) # 5 x 4 x 4 x 3out, mat = f(input)- assert_allclose(out, expected, rtol=1e-6, atol=1e-4)- assert_allclose(mat, expected_transform, rtol=1e-6, atol=1e-4)+ assert_close(out, expected, rtol=1e-6, atol=1e-4)+ assert_close(mat, expected_transform, rtol=1e-6, atol=1e-4)def test_same_on_batch(self, device, dtype):f = RandomRotation3D(degrees=40, same_on_batch=True)@@ -671,9 +671,9 @@ class TestRandomRotation3D:out, mat = f(input)_, mat_2 = f1(input)- assert_allclose(out, expected, rtol=1e-6, atol=1e-4)- assert_allclose(mat, expected_transform, rtol=1e-6, atol=1e-4)- assert_allclose(mat_2, expected_transform_2, rtol=1e-6, atol=1e-4)+ assert_close(out, expected, rtol=1e-6, atol=1e-4)+ assert_close(mat, expected_transform, rtol=1e-6, atol=1e-4)+ assert_close(mat_2, expected_transform_2, rtol=1e-6, atol=1e-4)def test_gradcheck(self, device):@@ -759,7 +759,7 @@ class TestRandomCrop3D:dtype=dtype,)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)def test_same_on_batch(self, device, dtype):f = RandomCrop3D(size=(2, 3, 4), padding=None, align_corners=True, p=1.0, same_on_batch=True)@@ -795,7 +795,7 @@ class TestRandomCrop3D:f = RandomCrop3D(size=(2, 3, 4), fill=10.0, padding=padding, align_corners=True, p=1.0)out = f(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)def test_pad_if_needed(self, device, dtype):torch.manual_seed(42)@@ -815,7 +815,7 @@ class TestRandomCrop3D:rc = RandomCrop3D(size=(2, 3, 4), pad_if_needed=True, fill=9, align_corners=True, p=1.0)out = rc(inp)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):torch.manual_seed(0) # for random reproductibility@@ -832,7 +832,7 @@ class TestRandomCrop3D:actual = op_script(img)expected = kornia.center_crop3d(img)- assert_allclose(actual, expected)+ assert_close(actual, expected)@pytest.mark.skip("Need to fix Union type")def test_jit_trace(self, device, dtype):@@ -850,7 +850,7 @@ class TestRandomCrop3D:# 3. Evaluateactual = op_trace(img)expected = op(img)- assert_allclose(actual, expected)+ assert_close(actual, expected)class TestCenterCrop3D:@@ -905,12 +905,12 @@ class TestRandomEqualize3D:identity = kornia.eye_like(4, expected)- assert_allclose(f(inputs3d)[0], expected, rtol=1e-4, atol=1e-4)- assert_allclose(f(inputs3d)[1], identity, rtol=1e-4, atol=1e-4)- assert_allclose(f1(inputs3d)[0], inputs3d, rtol=1e-4, atol=1e-4)- assert_allclose(f1(inputs3d)[1], identity, rtol=1e-4, atol=1e-4)- assert_allclose(f2(inputs3d), expected, rtol=1e-4, atol=1e-4)- assert_allclose(f3(inputs3d), inputs3d, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs3d)[0], expected, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs3d)[1], identity, rtol=1e-4, atol=1e-4)+ assert_close(f1(inputs3d)[0], inputs3d, rtol=1e-4, atol=1e-4)+ assert_close(f1(inputs3d)[1], identity, rtol=1e-4, atol=1e-4)+ assert_close(f2(inputs3d), expected, rtol=1e-4, atol=1e-4)+ assert_close(f3(inputs3d), inputs3d, rtol=1e-4, atol=1e-4)def test_batch_random_equalize(self, device, dtype):f = RandomEqualize3D(p=1.0, return_transform=True)@@ -927,12 +927,12 @@ class TestRandomEqualize3D:identity = kornia.eye_like(4, expected) # 2 x 4 x 4- assert_allclose(f(inputs3d)[0], expected, rtol=1e-4, atol=1e-4)- assert_allclose(f(inputs3d)[1], identity, rtol=1e-4, atol=1e-4)- assert_allclose(f1(inputs3d)[0], inputs3d, rtol=1e-4, atol=1e-4)- assert_allclose(f1(inputs3d)[1], identity, rtol=1e-4, atol=1e-4)- assert_allclose(f2(inputs3d), expected, rtol=1e-4, atol=1e-4)- assert_allclose(f3(inputs3d), inputs3d, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs3d)[0], expected, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs3d)[1], identity, rtol=1e-4, atol=1e-4)+ assert_close(f1(inputs3d)[0], inputs3d, rtol=1e-4, atol=1e-4)+ assert_close(f1(inputs3d)[1], identity, rtol=1e-4, atol=1e-4)+ assert_close(f2(inputs3d), expected, rtol=1e-4, atol=1e-4)+ assert_close(f3(inputs3d), inputs3d, rtol=1e-4, atol=1e-4)def test_same_on_batch(self, device, dtype):f = RandomEqualize3D(p=0.5, same_on_batch=True)diff --git a/test/augmentation/test_augmentation_mix.py b/test/augmentation/test_augmentation_mix.pyindex 165db3aee..873a57b7a 100644--- a/test/augmentation/test_augmentation_mix.py+++ b/test/augmentation/test_augmentation_mix.py@@ -1,7 +1,7 @@import torch-from torch.testing import assert_allclosefrom kornia.augmentation import RandomCutMix, RandomMixUp+from kornia.testing import assert_closeclass TestRandomMixUp:@@ -29,10 +29,10 @@ class TestRandomMixUp:out_image, out_label = f(input, label)- assert_allclose(out_image, expected, rtol=1e-4, atol=1e-4)+ assert_close(out_image, expected, rtol=1e-4, atol=1e-4)assert (out_label[:, 0] == label).all()assert (out_label[:, 1] == torch.tensor([0, 1], device=device, dtype=dtype)).all()- assert_allclose(out_label[:, 2], lam, rtol=1e-4, atol=1e-4)+ assert_close(out_label[:, 2], lam, rtol=1e-4, atol=1e-4)def test_random_mixup_p0(self, device, dtype):torch.manual_seed(0)@@ -48,7 +48,7 @@ class TestRandomMixUp:out_image, out_label = f(input, label)- assert_allclose(out_image, expected, rtol=1e-4, atol=1e-4)+ assert_close(out_image, expected, rtol=1e-4, atol=1e-4)assert (out_label == label).all()def test_random_mixup_lam0(self, device, dtype):@@ -65,10 +65,10 @@ class TestRandomMixUp:out_image, out_label = f(input, label)- assert_allclose(out_image, expected, rtol=1e-4, atol=1e-4)+ assert_close(out_image, expected, rtol=1e-4, atol=1e-4)assert (out_label[:, 0] == label).all()assert (out_label[:, 1] == torch.tensor([0, 1], device=device)).all()- assert_allclose(out_label[:, 2], lam, rtol=1e-4, atol=1e-4)+ assert_close(out_label[:, 2], lam, rtol=1e-4, atol=1e-4)def test_random_mixup_same_on_batch(self, device, dtype):torch.manual_seed(0)@@ -88,10 +88,10 @@ class TestRandomMixUp:)out_image, out_label = f(input, label)- assert_allclose(out_image, expected, rtol=1e-4, atol=1e-4)+ assert_close(out_image, expected, rtol=1e-4, atol=1e-4)assert (out_label[:, 0] == label).all()assert (out_label[:, 1] == torch.tensor([0, 1], device=device, dtype=dtype)).all()- assert_allclose(out_label[:, 2], lam, rtol=1e-4, atol=1e-4)+ assert_close(out_label[:, 2], lam, rtol=1e-4, atol=1e-4)class TestRandomCutMix:@@ -124,7 +124,7 @@ class TestRandomCutMix:out_image, out_label = f(input, label)- assert_allclose(out_image, expected, rtol=1e-4, atol=1e-4)+ assert_close(out_image, expected, rtol=1e-4, atol=1e-4)assert (out_label[0, :, 0] == label).all()assert (out_label[0, :, 1] == torch.tensor([0, 1], device=device, dtype=dtype)).all()assert (out_label[0, :, 2] == torch.tensor([0.5, 0.5], device=device, dtype=dtype)).all()@@ -142,7 +142,7 @@ class TestRandomCutMix:out_image, out_label = f(input, label)- assert_allclose(out_image, expected, rtol=1e-4, atol=1e-4)+ assert_close(out_image, expected, rtol=1e-4, atol=1e-4)assert (out_label == label).all()def test_random_mixup_beta0(self, device, dtype):@@ -167,11 +167,11 @@ class TestRandomCutMix:out_image, out_label = f(input, label)- assert_allclose(out_image, expected, rtol=1e-4, atol=1e-4)+ assert_close(out_image, expected, rtol=1e-4, atol=1e-4)assert (out_label[0, :, 0] == label).all()assert (out_label[0, :, 1] == torch.tensor([0, 1], device=device, dtype=dtype)).all()# cut area = 4 / 12- assert_allclose(out_label[0, :, 2], torch.tensor([0.33333, 0.33333], device=device, dtype=dtype))+ assert_close(out_label[0, :, 2], torch.tensor([0.33333, 0.33333], device=device, dtype=dtype))def test_random_mixup_num2(self, device, dtype):torch.manual_seed(76)@@ -193,10 +193,10 @@ class TestRandomCutMix:out_image, out_label = f(input, label)- assert_allclose(out_image, expected, rtol=1e-4, atol=1e-4)+ assert_close(out_image, expected, rtol=1e-4, atol=1e-4)assert (out_label[:, :, 0] == label).all()assert (out_label[:, :, 1] == torch.tensor([[1, 0], [1, 0], [1, 0], [1, 0], [0, 1]], device=device)).all()- assert_allclose(+ assert_close(out_label[:, :, 2],torch.tensor([[0.0833, 0.3333], [0.0, 0.1667], [0.5, 0.0833], [0.0833, 0.0], [0.5, 0.3333]],@@ -228,9 +228,9 @@ class TestRandomCutMix:out_image, out_label = f(input, label)- assert_allclose(out_image, expected, rtol=1e-4, atol=1e-4)+ assert_close(out_image, expected, rtol=1e-4, atol=1e-4)assert (out_label[0, :, 0] == label).all()assert (out_label[0, :, 1] == torch.tensor([0, 1], device=device, dtype=dtype)).all()- assert_allclose(+ assert_close(out_label[0, :, 2], torch.tensor([0.5000, 0.5000], device=device, dtype=dtype), rtol=1e-4, atol=1e-4)diff --git a/test/augmentation/test_base.py b/test/augmentation/test_base.pyindex 661048907..ab1207d94 100644--- a/test/augmentation/test_base.py+++ b/test/augmentation/test_base.py@@ -3,10 +3,10 @@ from unittest.mock import patchimport pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia.testing as utils # test utilsfrom kornia.augmentation.base import _BasicAugmentationBase, AugmentationBase2D+from kornia.testing import assert_closeclass TestBasicAugmentationBase:@@ -22,7 +22,7 @@ class TestBasicAugmentationBase:transform_tensor.side_effect = lambda x: x.unsqueeze(dim=2)output = augmentation.transform_tensor(input)assert output.shape == torch.Size([2, 3, 1, 4, 5])- assert_allclose(input, output[:, :, 0, :, :])+ assert_close(input, output[:, :, 0, :, :])@pytest.mark.parametrize("p,p_batch,same_on_batch,num,seed",@@ -71,7 +71,7 @@ class TestBasicAugmentationBase:check_batching.side_effect = lambda input: Noneoutput = augmentation(input)assert output.shape == expected_output.shape- assert_allclose(output, expected_output)+ assert_close(output, expected_output)class TestAugmentationBase2D:@@ -123,7 +123,7 @@ class TestAugmentationBase2D:# return the expected tensor and transformation.output, transformation = augmentation(input, return_transform=True)assert output is expected_output- assert_allclose(transformation, expected_transform)+ assert_close(transformation, expected_transform)# Calling the augmentation with a tensor and params shall return the expected tensor using the given params.params = {'params': {}, 'flags': {'bar': 1}}diff --git a/test/augmentation/test_container.py b/test/augmentation/test_container.pyindex 8d48806a1..2fa98b87a 100644--- a/test/augmentation/test_container.py+++ b/test/augmentation/test_container.py@@ -1,11 +1,11 @@import pytestimport torch-from torch.testing import assert_allcloseimport korniaimport kornia.augmentation as Kfrom kornia.constants import BorderTypefrom kornia.geometry.transform import bbox_to_mask+from kornia.testing import assert_closedef reproducibility_test(input, seq):@@ -135,7 +135,7 @@ class TestVideoSequential:img = torch.ones(B, C, D, H, W, device=device, dtype=dtype)op = K.VideoSequential(K.ColorJitter(0.1, 0.1, 0.1, 0.1), same_on_frame=True)op_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))class TestSequential:@@ -303,7 +303,7 @@ class TestAugmentationSequential:K.ColorJitter(0.1, 0.1, 0.1, 0.1, p=1.0), K.RandomAffine(360, p=1.0), same_on_batch=True)op_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))class TestPatchSequential:diff --git a/test/augmentation/test_motionblur.py b/test/augmentation/test_motionblur.pyindex 80a2269c1..69266dbb7 100644--- a/test/augmentation/test_motionblur.py+++ b/test/augmentation/test_motionblur.py@@ -1,12 +1,11 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniafrom kornia.augmentation import RandomMotionBlur, RandomMotionBlur3Dfrom kornia.filters import motion_blur, motion_blur3d-from kornia.testing import tensor_to_gradcheck_var+from kornia.testing import assert_close, tensor_to_gradcheck_varclass TestRandomMotionBlur:@@ -44,12 +43,12 @@ class TestRandomMotionBlur:assert len(output) == 2, f"must return a length 2 tuple if return_transform is True. Got {len(output)}."identity = kornia.eye_like(3, input)output, mat = output- assert_allclose(mat, identity, rtol=1e-4, atol=1e-4)+ assert_close(mat, identity, rtol=1e-4, atol=1e-4)if same_on_batch:- assert_allclose(output[0], output[1], rtol=1e-4, atol=1e-4)+ assert_close(output[0], output[1], rtol=1e-4, atol=1e-4)elif p == 0:- assert_allclose(output, input, rtol=1e-4, atol=1e-4)+ assert_close(output, input, rtol=1e-4, atol=1e-4)else:assert not torch.allclose(output[0], output[1], rtol=1e-4, atol=1e-4)@@ -71,7 +70,7 @@ class TestRandomMotionBlur:f.border_type.name.lower(),)- assert_allclose(output, expected, rtol=1e-4, atol=1e-4)+ assert_close(output, expected, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device):torch.manual_seed(0) # for random reproductibility@@ -126,12 +125,12 @@ class TestRandomMotionBlur3D:assert len(output) == 2, f"must return a length 2 tuple if return_transform is True. Got {len(output)}."identity = kornia.eye_like(4, input)output, mat = output- assert_allclose(mat, identity, rtol=1e-4, atol=1e-4)+ assert_close(mat, identity, rtol=1e-4, atol=1e-4)if same_on_batch:- assert_allclose(output[0], output[1], rtol=1e-4, atol=1e-4)+ assert_close(output[0], output[1], rtol=1e-4, atol=1e-4)elif p == 0:- assert_allclose(output, input, rtol=1e-4, atol=1e-4)+ assert_close(output, input, rtol=1e-4, atol=1e-4)else:assert not torch.allclose(output[0], output[1], rtol=1e-4, atol=1e-4)@@ -153,7 +152,7 @@ class TestRandomMotionBlur3D:f.border_type.name.lower(),)- assert_allclose(output, expected, rtol=1e-4, atol=1e-4)+ assert_close(output, expected, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device, dtype):torch.manual_seed(0) # for random reproductibilitydiff --git a/test/augmentation/test_perspective.py b/test/augmentation/test_perspective.pyindex 475127e86..24c2ba999 100644--- a/test/augmentation/test_perspective.py+++ b/test/augmentation/test_perspective.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestRandomPerspective:@@ -62,8 +62,8 @@ class TestRandomPerspective:assert len(out_perspective) == 2assert out_perspective[0].shape == x_data.shapeassert out_perspective[1].shape == (1, 3, 3)- assert_allclose(out_perspective[0], x_data)- assert_allclose(out_perspective[1], torch.eye(3, device=device)[None])+ assert_close(out_perspective[0], x_data)+ assert_close(out_perspective[1], torch.eye(3, device=device)[None])assert aug.inverse(out_perspective).shape == x_data.shapedef test_transform_module_should_return_expected_transform(self, device):@@ -105,8 +105,8 @@ class TestRandomPerspective:assert len(out_perspective) == 2assert out_perspective[0].shape == x_data.shapeassert out_perspective[1].shape == (1, 3, 3)- assert_allclose(out_perspective[0], expected_output, atol=1e-4, rtol=1e-4)- assert_allclose(out_perspective[1], expected_transform, atol=1e-4, rtol=1e-4)+ assert_close(out_perspective[0], expected_output, atol=1e-4, rtol=1e-4)+ assert_close(out_perspective[1], expected_transform, atol=1e-4, rtol=1e-4)assert aug.inverse(out_perspective).shape == x_data.shapedef test_gradcheck(self, device):diff --git a/test/augmentation/test_random_generator.py b/test/augmentation/test_random_generator.pyindex abf2dab35..087b7bcd5 100644--- a/test/augmentation/test_random_generator.py+++ b/test/augmentation/test_random_generator.py@@ -1,6 +1,5 @@import pytestimport torch-from torch.testing import assert_allclosefrom kornia.augmentation.random_generator import (center_crop_generator,@@ -19,6 +18,7 @@ from kornia.augmentation.random_generator import (random_sharpness_generator,random_solarize_generator,)+from kornia.testing import assert_closeclass RandomGeneratorBaseTests:@@ -161,17 +161,15 @@ class TestColorJitterGen(RandomGeneratorBaseTests):}, "Redundant keys found apart from \'brightness_factor', 'contrast_factor', 'hue_factor', 'saturation_factor', 'order'"- assert_allclose(+ assert_close(jitter_params['brightness_factor'], expected_jitter_params['brightness_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(- jitter_params['contrast_factor'], expected_jitter_params['contrast_factor'], rtol=1e-4, atol=1e-4- )- assert_allclose(jitter_params['hue_factor'], expected_jitter_params['hue_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(+ assert_close(jitter_params['contrast_factor'], expected_jitter_params['contrast_factor'], rtol=1e-4, atol=1e-4)+ assert_close(jitter_params['hue_factor'], expected_jitter_params['hue_factor'], rtol=1e-4, atol=1e-4)+ assert_close(jitter_params['saturation_factor'], expected_jitter_params['saturation_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(jitter_params['order'].to(dtype), expected_jitter_params['order'], rtol=1e-4, atol=1e-4)+ assert_close(jitter_params['order'].to(dtype), expected_jitter_params['order'], rtol=1e-4, atol=1e-4)def test_same_on_batch(self, device, dtype):torch.manual_seed(42)@@ -193,11 +191,11 @@ class TestColorJitterGen(RandomGeneratorBaseTests):'order': torch.tensor([2, 3, 0, 1], device=device, dtype=dtype),}- assert_allclose(jitter_params['brightness_factor'], expected_res['brightness_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(jitter_params['contrast_factor'], expected_res['contrast_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(jitter_params['hue_factor'], expected_res['hue_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(jitter_params['saturation_factor'], expected_res['saturation_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(jitter_params['order'].to(dtype), expected_res['order'], rtol=1e-4, atol=1e-4)+ assert_close(jitter_params['brightness_factor'], expected_res['brightness_factor'], rtol=1e-4, atol=1e-4)+ assert_close(jitter_params['contrast_factor'], expected_res['contrast_factor'], rtol=1e-4, atol=1e-4)+ assert_close(jitter_params['hue_factor'], expected_res['hue_factor'], rtol=1e-4, atol=1e-4)+ assert_close(jitter_params['saturation_factor'], expected_res['saturation_factor'], rtol=1e-4, atol=1e-4)+ assert_close(jitter_params['order'].to(dtype), expected_res['order'], rtol=1e-4, atol=1e-4)class TestRandomPerspectiveGen(RandomGeneratorBaseTests):@@ -257,8 +255,8 @@ class TestRandomPerspectiveGen(RandomGeneratorBaseTests):),)assert res.keys() == expected.keys()- assert_allclose(res['start_points'], expected['start_points'])- assert_allclose(res['end_points'], expected['end_points'])+ assert_close(res['start_points'], expected['start_points'])+ assert_close(res['end_points'], expected['end_points'])def test_same_on_batch(self, device, dtype):torch.manual_seed(42)@@ -277,8 +275,8 @@ class TestRandomPerspectiveGen(RandomGeneratorBaseTests):).repeat(2, 1, 1),)assert res.keys() == expected.keys()- assert_allclose(res['start_points'], expected['start_points'])- assert_allclose(res['end_points'], expected['end_points'])+ assert_close(res['start_points'], expected['start_points'])+ assert_close(res['end_points'], expected['end_points'])class TestRandomAffineGen(RandomGeneratorBaseTests):@@ -359,12 +357,12 @@ class TestRandomAffineGen(RandomGeneratorBaseTests):sy=torch.tensor([19.3460, 15.9358], device=device, dtype=dtype),)assert res.keys() == expected.keys()- assert_allclose(res['translations'], expected['translations'], rtol=1e-4, atol=1e-4)- assert_allclose(res['center'], expected['center'], rtol=1e-4, atol=1e-4)- assert_allclose(res['scale'], expected['scale'], rtol=1e-4, atol=1e-4)- assert_allclose(res['angle'], expected['angle'], rtol=1e-4, atol=1e-4)- assert_allclose(res['sx'], expected['sx'], rtol=1e-4, atol=1e-4)- assert_allclose(res['sy'], expected['sy'], rtol=1e-4, atol=1e-4)+ assert_close(res['translations'], expected['translations'], rtol=1e-4, atol=1e-4)+ assert_close(res['center'], expected['center'], rtol=1e-4, atol=1e-4)+ assert_close(res['scale'], expected['scale'], rtol=1e-4, atol=1e-4)+ assert_close(res['angle'], expected['angle'], rtol=1e-4, atol=1e-4)+ assert_close(res['sx'], expected['sx'], rtol=1e-4, atol=1e-4)+ assert_close(res['sy'], expected['sy'], rtol=1e-4, atol=1e-4)def test_same_on_batch(self, device, dtype):torch.manual_seed(42)@@ -391,12 +389,12 @@ class TestRandomAffineGen(RandomGeneratorBaseTests):sy=torch.tensor([16.0090, 16.0090], device=device, dtype=dtype),)assert res.keys() == expected.keys()- assert_allclose(res['translations'], expected['translations'], rtol=1e-4, atol=1e-4)- assert_allclose(res['center'], expected['center'], rtol=1e-4, atol=1e-4)- assert_allclose(res['scale'], expected['scale'], rtol=1e-4, atol=1e-4)- assert_allclose(res['angle'], expected['angle'], rtol=1e-4, atol=1e-4)- assert_allclose(res['sx'], expected['sx'], rtol=1e-4, atol=1e-4)- assert_allclose(res['sy'], expected['sy'], rtol=1e-4, atol=1e-4)+ assert_close(res['translations'], expected['translations'], rtol=1e-4, atol=1e-4)+ assert_close(res['center'], expected['center'], rtol=1e-4, atol=1e-4)+ assert_close(res['scale'], expected['scale'], rtol=1e-4, atol=1e-4)+ assert_close(res['angle'], expected['angle'], rtol=1e-4, atol=1e-4)+ assert_close(res['sx'], expected['sx'], rtol=1e-4, atol=1e-4)+ assert_close(res['sy'], expected['sy'], rtol=1e-4, atol=1e-4)class TestRandomRotationGen(RandomGeneratorBaseTests):@@ -422,7 +420,7 @@ class TestRandomRotationGen(RandomGeneratorBaseTests):)expected = dict(degrees=torch.tensor([18.8227, 19.1500], device=device, dtype=dtype))assert res.keys() == expected.keys()- assert_allclose(res['degrees'], expected['degrees'])+ assert_close(res['degrees'], expected['degrees'])def test_same_on_batch(self, device, dtype):torch.manual_seed(42)@@ -432,7 +430,7 @@ class TestRandomRotationGen(RandomGeneratorBaseTests):)expected = dict(degrees=torch.tensor([18.8227, 18.8227], device=device, dtype=dtype))assert res.keys() == expected.keys()- assert_allclose(res['degrees'], expected['degrees'])+ assert_close(res['degrees'], expected['degrees'])class TestRandomCropGen(RandomGeneratorBaseTests):@@ -491,8 +489,8 @@ class TestRandomCropGen(RandomGeneratorBaseTests):input_size=torch.tensor([[100, 100], [100, 100]], device=device, dtype=torch.long),)assert res.keys() == expected.keys()- assert_allclose(res['src'], expected['src'])- assert_allclose(res['dst'], expected['dst'])+ assert_close(res['src'], expected['src'])+ assert_close(res['dst'], expected['dst'])def test_same_on_batch(self, device, dtype):torch.manual_seed(42)@@ -518,8 +516,8 @@ class TestRandomCropGen(RandomGeneratorBaseTests):input_size=torch.tensor([[100, 100], [100, 100]], device=device, dtype=torch.long),)assert res.keys() == expected.keys()- assert_allclose(res['src'], expected['src'])- assert_allclose(res['dst'], expected['dst'])+ assert_close(res['src'], expected['src'])+ assert_close(res['dst'], expected['dst'])class TestRandomCropSizeGen(RandomGeneratorBaseTests):@@ -576,7 +574,7 @@ class TestRandomCropSizeGen(RandomGeneratorBaseTests):))assert res.keys() == expected.keys()- assert_allclose(res['size'], expected['size'])+ assert_close(res['size'], expected['size'])res = random_crop_size_generator(batch_size=100,@@ -587,7 +585,7 @@ class TestRandomCropSizeGen(RandomGeneratorBaseTests):)expected = dict(size=torch.tensor([[100, 100]], device=device, dtype=dtype).repeat(100, 1))assert res.keys() == expected.keys()- assert_allclose(res['size'], expected['size'])+ assert_close(res['size'], expected['size'])def test_same_on_batch(self, device, dtype):torch.manual_seed(42)@@ -607,7 +605,7 @@ class TestRandomCropSizeGen(RandomGeneratorBaseTests):))assert res.keys() == expected.keys()- assert_allclose(res['size'], expected['size'])+ assert_close(res['size'], expected['size'])class TestRandomRectangleGen(RandomGeneratorBaseTests):@@ -675,11 +673,11 @@ class TestRandomRectangleGen(RandomGeneratorBaseTests):values=torch.tensor([0.5000, 0.5000], device=device, dtype=dtype),)assert res.keys() == expected.keys()- assert_allclose(res['widths'], expected['widths'])- assert_allclose(res['widths'], expected['widths'])- assert_allclose(res['xs'], expected['xs'])- assert_allclose(res['ys'], expected['ys'])- assert_allclose(res['values'], expected['values'])+ assert_close(res['widths'], expected['widths'])+ assert_close(res['widths'], expected['widths'])+ assert_close(res['xs'], expected['xs'])+ assert_close(res['ys'], expected['ys'])+ assert_close(res['values'], expected['values'])def test_same_on_batch(self, device, dtype):torch.manual_seed(42)@@ -698,11 +696,11 @@ class TestRandomRectangleGen(RandomGeneratorBaseTests):values=torch.tensor([0.5000, 0.5000], device=device, dtype=dtype),)assert res.keys() == expected.keys()- assert_allclose(res['widths'], expected['widths'])- assert_allclose(res['widths'], expected['widths'])- assert_allclose(res['xs'], expected['xs'])- assert_allclose(res['ys'], expected['ys'])- assert_allclose(res['values'], expected['values'])+ assert_close(res['widths'], expected['widths'])+ assert_close(res['widths'], expected['widths'])+ assert_close(res['xs'], expected['xs'])+ assert_close(res['ys'], expected['ys'])+ assert_close(res['values'], expected['values'])class TestCenterCropGen(RandomGeneratorBaseTests):@@ -745,8 +743,8 @@ class TestCenterCropGen(RandomGeneratorBaseTests):input_size=torch.tensor([[200, 200], [200, 200]], device=device, dtype=torch.long),)assert res.keys() == expected.keys()- assert_allclose(res['src'].to(device=device), expected['src'])- assert_allclose(res['dst'].to(device=device), expected['dst'])+ assert_close(res['src'].to(device=device), expected['src'])+ assert_close(res['dst'].to(device=device), expected['dst'])def test_same_on_batch(self, device, dtype):pass@@ -803,9 +801,9 @@ class TestRandomMotionBlur(RandomGeneratorBaseTests):direction_factor=torch.tensor([-0.2343, 0.9186], device=device, dtype=dtype),)assert res.keys() == expected.keys()- assert_allclose(res['ksize_factor'], expected['ksize_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(res['angle_factor'], expected['angle_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(res['direction_factor'], expected['direction_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['ksize_factor'], expected['ksize_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['angle_factor'], expected['angle_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['direction_factor'], expected['direction_factor'], rtol=1e-4, atol=1e-4)def test_same_on_batch(self, device, dtype):torch.manual_seed(42)@@ -824,9 +822,9 @@ class TestRandomMotionBlur(RandomGeneratorBaseTests):direction_factor=torch.tensor([0.8300, 0.8300], device=device, dtype=dtype),)assert res.keys() == expected.keys()- assert_allclose(res['ksize_factor'], expected['ksize_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(res['angle_factor'], expected['angle_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(res['direction_factor'], expected['direction_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['ksize_factor'], expected['ksize_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['angle_factor'], expected['angle_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['direction_factor'], expected['direction_factor'], rtol=1e-4, atol=1e-4)class TestRandomSolarizeGen(RandomGeneratorBaseTests):@@ -879,8 +877,8 @@ class TestRandomSolarizeGen(RandomGeneratorBaseTests):),)assert res.keys() == expected.keys()- assert_allclose(res['thresholds_factor'], expected['thresholds_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(res['additions_factor'], expected['additions_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['thresholds_factor'], expected['thresholds_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['additions_factor'], expected['additions_factor'], rtol=1e-4, atol=1e-4)def test_same_on_batch(self, device, dtype):torch.manual_seed(42)@@ -900,8 +898,8 @@ class TestRandomSolarizeGen(RandomGeneratorBaseTests):),)assert res.keys() == expected.keys()- assert_allclose(res['thresholds_factor'], expected['thresholds_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(res['additions_factor'], expected['additions_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['thresholds_factor'], expected['thresholds_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['additions_factor'], expected['additions_factor'], rtol=1e-4, atol=1e-4)class TestRandomPosterizeGen(RandomGeneratorBaseTests):@@ -928,7 +926,7 @@ class TestRandomPosterizeGen(RandomGeneratorBaseTests):)expected = dict(bits_factor=torch.tensor([5, 2, 3, 6, 7, 7, 2, 7], device=device, dtype=torch.int32))assert res.keys() == expected.keys()- assert_allclose(res['bits_factor'], expected['bits_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['bits_factor'], expected['bits_factor'], rtol=1e-4, atol=1e-4)def test_same_on_batch(self, device, dtype):torch.manual_seed(9)@@ -938,7 +936,7 @@ class TestRandomPosterizeGen(RandomGeneratorBaseTests):)expected = dict(bits_factor=torch.tensor([5, 5, 5, 5, 5, 5, 5, 5], device=device, dtype=torch.int32))assert res.keys() == expected.keys()- assert_allclose(res['bits_factor'], expected['bits_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['bits_factor'], expected['bits_factor'], rtol=1e-4, atol=1e-4)class TestRandomSharpnessGen(RandomGeneratorBaseTests):@@ -969,7 +967,7 @@ class TestRandomSharpnessGen(RandomGeneratorBaseTests):))assert res.keys() == expected.keys()- assert_allclose(res['sharpness_factor'], expected['sharpness_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['sharpness_factor'], expected['sharpness_factor'], rtol=1e-4, atol=1e-4)def test_same_on_batch(self, device, dtype):torch.manual_seed(42)@@ -983,7 +981,7 @@ class TestRandomSharpnessGen(RandomGeneratorBaseTests):))assert res.keys() == expected.keys()- assert_allclose(res['sharpness_factor'], expected['sharpness_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['sharpness_factor'], expected['sharpness_factor'], rtol=1e-4, atol=1e-4)class TestRandomMixUpGen(RandomGeneratorBaseTests):@@ -1024,8 +1022,8 @@ class TestRandomMixUpGen(RandomGeneratorBaseTests):),)assert res.keys() == expected.keys()- assert_allclose(res['mixup_pairs'], expected['mixup_pairs'], rtol=1e-4, atol=1e-4)- assert_allclose(res['mixup_lambdas'], expected['mixup_lambdas'], rtol=1e-4, atol=1e-4)+ assert_close(res['mixup_pairs'], expected['mixup_pairs'], rtol=1e-4, atol=1e-4)+ assert_close(res['mixup_lambdas'], expected['mixup_lambdas'], rtol=1e-4, atol=1e-4)def test_same_on_batch(self, device, dtype):torch.manual_seed(9)@@ -1043,8 +1041,8 @@ class TestRandomMixUpGen(RandomGeneratorBaseTests):),)assert res.keys() == expected.keys()- assert_allclose(res['mixup_pairs'], expected['mixup_pairs'], rtol=1e-4, atol=1e-4)- assert_allclose(res['mixup_lambdas'], expected['mixup_lambdas'], rtol=1e-4, atol=1e-4)+ assert_close(res['mixup_pairs'], expected['mixup_pairs'], rtol=1e-4, atol=1e-4)+ assert_close(res['mixup_lambdas'], expected['mixup_lambdas'], rtol=1e-4, atol=1e-4)class TestRandomCutMixGen(RandomGeneratorBaseTests):@@ -1117,8 +1115,8 @@ class TestRandomCutMixGen(RandomGeneratorBaseTests):),)assert res.keys() == expected.keys()- assert_allclose(res['mix_pairs'], expected['mix_pairs'], rtol=1e-4, atol=1e-4)- assert_allclose(res['crop_src'], expected['crop_src'], rtol=1e-4, atol=1e-4)+ assert_close(res['mix_pairs'], expected['mix_pairs'], rtol=1e-4, atol=1e-4)+ assert_close(res['crop_src'], expected['crop_src'], rtol=1e-4, atol=1e-4)def test_same_on_batch(self, device, dtype):torch.manual_seed(42)@@ -1142,5 +1140,5 @@ class TestRandomCutMixGen(RandomGeneratorBaseTests):),)assert res.keys() == expected.keys()- assert_allclose(res['mix_pairs'], expected['mix_pairs'], rtol=1e-4, atol=1e-4)- assert_allclose(res['crop_src'], expected['crop_src'], rtol=1e-4, atol=1e-4)+ assert_close(res['mix_pairs'], expected['mix_pairs'], rtol=1e-4, atol=1e-4)+ assert_close(res['crop_src'], expected['crop_src'], rtol=1e-4, atol=1e-4)diff --git a/test/augmentation/test_random_generator_3d.py b/test/augmentation/test_random_generator_3d.pyindex c5eabf720..16f41dad4 100644--- a/test/augmentation/test_random_generator_3d.py+++ b/test/augmentation/test_random_generator_3d.py@@ -1,6 +1,5 @@import pytestimport torch-from torch.testing import assert_allclosefrom kornia.augmentation.random_generator import (center_crop_generator3d,@@ -10,6 +9,7 @@ from kornia.augmentation.random_generator import (random_perspective_generator3d,random_rotation_generator3d,)+from kornia.testing import assert_closeclass RandomGeneratorBaseTests:@@ -122,8 +122,8 @@ class TestRandomPerspectiveGen3D(RandomGeneratorBaseTests):),)assert res.keys() == expected.keys()- assert_allclose(res['start_points'], expected['start_points'], atol=1e-4, rtol=1e-4)- assert_allclose(res['end_points'], expected['end_points'], atol=1e-4, rtol=1e-4)+ assert_close(res['start_points'], expected['start_points'], atol=1e-4, rtol=1e-4)+ assert_close(res['end_points'], expected['end_points'], atol=1e-4, rtol=1e-4)def test_same_on_batch(self, device, dtype):torch.manual_seed(42)@@ -186,8 +186,8 @@ class TestRandomPerspectiveGen3D(RandomGeneratorBaseTests):),)assert res.keys() == expected.keys()- assert_allclose(res['start_points'], expected['start_points'], atol=1e-4, rtol=1e-4)- assert_allclose(res['end_points'], expected['end_points'], atol=1e-4, rtol=1e-4)+ assert_close(res['start_points'], expected['start_points'], atol=1e-4, rtol=1e-4)+ assert_close(res['end_points'], expected['end_points'], atol=1e-4, rtol=1e-4)class TestRandomAffineGen3D(RandomGeneratorBaseTests):@@ -273,16 +273,16 @@ class TestRandomAffineGen3D(RandomGeneratorBaseTests):szy=torch.tensor([10.9438, 0.1232], device=device, dtype=dtype),)assert res.keys() == expected.keys()- assert_allclose(res['translations'], expected['translations'], rtol=1e-4, atol=1e-4)- assert_allclose(res['center'], expected['center'], rtol=1e-4, atol=1e-4)- assert_allclose(res['scale'], expected['scale'], rtol=1e-4, atol=1e-4)- assert_allclose(res['angles'], expected['angles'], rtol=1e-4, atol=1e-4)- assert_allclose(res['sxy'], expected['sxy'], rtol=1e-4, atol=1e-4)- assert_allclose(res['sxz'], expected['sxz'], rtol=1e-4, atol=1e-4)- assert_allclose(res['syx'], expected['syx'], rtol=1e-4, atol=1e-4)- assert_allclose(res['syz'], expected['syz'], rtol=1e-4, atol=1e-4)- assert_allclose(res['szx'], expected['szx'], rtol=1e-4, atol=1e-4)- assert_allclose(res['szy'], expected['szy'], rtol=1e-4, atol=1e-4)+ assert_close(res['translations'], expected['translations'], rtol=1e-4, atol=1e-4)+ assert_close(res['center'], expected['center'], rtol=1e-4, atol=1e-4)+ assert_close(res['scale'], expected['scale'], rtol=1e-4, atol=1e-4)+ assert_close(res['angles'], expected['angles'], rtol=1e-4, atol=1e-4)+ assert_close(res['sxy'], expected['sxy'], rtol=1e-4, atol=1e-4)+ assert_close(res['sxz'], expected['sxz'], rtol=1e-4, atol=1e-4)+ assert_close(res['syx'], expected['syx'], rtol=1e-4, atol=1e-4)+ assert_close(res['syz'], expected['syz'], rtol=1e-4, atol=1e-4)+ assert_close(res['szx'], expected['szx'], rtol=1e-4, atol=1e-4)+ assert_close(res['szy'], expected['szy'], rtol=1e-4, atol=1e-4)def test_same_on_batch(self, device, dtype):torch.manual_seed(42)@@ -316,16 +316,16 @@ class TestRandomAffineGen3D(RandomGeneratorBaseTests):szy=torch.tensor([14.8219, 14.8219], device=device, dtype=dtype),)assert res.keys() == expected.keys()- assert_allclose(res['translations'], expected['translations'], rtol=1e-4, atol=1e-4)- assert_allclose(res['center'], expected['center'], rtol=1e-4, atol=1e-4)- assert_allclose(res['scale'], expected['scale'], rtol=1e-4, atol=1e-4)- assert_allclose(res['angles'], expected['angles'], rtol=1e-4, atol=1e-4)- assert_allclose(res['sxy'], expected['sxy'], rtol=1e-4, atol=1e-4)- assert_allclose(res['sxz'], expected['sxz'], rtol=1e-4, atol=1e-4)- assert_allclose(res['syx'], expected['syx'], rtol=1e-4, atol=1e-4)- assert_allclose(res['syz'], expected['syz'], rtol=1e-4, atol=1e-4)- assert_allclose(res['szx'], expected['szx'], rtol=1e-4, atol=1e-4)- assert_allclose(res['szy'], expected['szy'], rtol=1e-4, atol=1e-4)+ assert_close(res['translations'], expected['translations'], rtol=1e-4, atol=1e-4)+ assert_close(res['center'], expected['center'], rtol=1e-4, atol=1e-4)+ assert_close(res['scale'], expected['scale'], rtol=1e-4, atol=1e-4)+ assert_close(res['angles'], expected['angles'], rtol=1e-4, atol=1e-4)+ assert_close(res['sxy'], expected['sxy'], rtol=1e-4, atol=1e-4)+ assert_close(res['sxz'], expected['sxz'], rtol=1e-4, atol=1e-4)+ assert_close(res['syx'], expected['syx'], rtol=1e-4, atol=1e-4)+ assert_close(res['syz'], expected['syz'], rtol=1e-4, atol=1e-4)+ assert_close(res['szx'], expected['szx'], rtol=1e-4, atol=1e-4)+ assert_close(res['szy'], expected['szy'], rtol=1e-4, atol=1e-4)class TestRandomRotationGen3D(RandomGeneratorBaseTests):@@ -357,9 +357,9 @@ class TestRandomRotationGen3D(RandomGeneratorBaseTests):roll=torch.tensor([11.7134, 18.0269], device=device, dtype=dtype),)assert res.keys() == expected.keys()- assert_allclose(res['yaw'], expected['yaw'], atol=1e-4, rtol=1e-4)- assert_allclose(res['pitch'], expected['pitch'], atol=1e-4, rtol=1e-4)- assert_allclose(res['roll'], expected['roll'], atol=1e-4, rtol=1e-4)+ assert_close(res['yaw'], expected['yaw'], atol=1e-4, rtol=1e-4)+ assert_close(res['pitch'], expected['pitch'], atol=1e-4, rtol=1e-4)+ assert_close(res['roll'], expected['roll'], atol=1e-4, rtol=1e-4)def test_same_on_batch(self, device, dtype):torch.manual_seed(42)@@ -373,9 +373,9 @@ class TestRandomRotationGen3D(RandomGeneratorBaseTests):roll=torch.tensor([11.4859, 11.4859], device=device, dtype=dtype),)assert res.keys() == expected.keys()- assert_allclose(res['yaw'], expected['yaw'], atol=1e-4, rtol=1e-4)- assert_allclose(res['pitch'], expected['pitch'], atol=1e-4, rtol=1e-4)- assert_allclose(res['roll'], expected['roll'], atol=1e-4, rtol=1e-4)+ assert_close(res['yaw'], expected['yaw'], atol=1e-4, rtol=1e-4)+ assert_close(res['pitch'], expected['pitch'], atol=1e-4, rtol=1e-4)+ assert_close(res['roll'], expected['roll'], atol=1e-4, rtol=1e-4)class TestRandomCropGen3D(RandomGeneratorBaseTests):@@ -476,8 +476,8 @@ class TestRandomCropGen3D(RandomGeneratorBaseTests):),)assert res.keys() == expected.keys()- assert_allclose(res['src'], expected['src'], atol=1e-4, rtol=1e-4)- assert_allclose(res['dst'], expected['dst'], atol=1e-4, rtol=1e-4)+ assert_close(res['src'], expected['src'], atol=1e-4, rtol=1e-4)+ assert_close(res['dst'], expected['dst'], atol=1e-4, rtol=1e-4)def test_same_on_batch(self, device, dtype):torch.manual_seed(42)@@ -543,8 +543,8 @@ class TestRandomCropGen3D(RandomGeneratorBaseTests):),)assert res.keys() == expected.keys()- assert_allclose(res['src'], expected['src'], atol=1e-4, rtol=1e-4)- assert_allclose(res['dst'], expected['dst'], atol=1e-4, rtol=1e-4)+ assert_close(res['src'], expected['src'], atol=1e-4, rtol=1e-4)+ assert_close(res['dst'], expected['dst'], atol=1e-4, rtol=1e-4)class TestCenterCropGen3D(RandomGeneratorBaseTests):@@ -606,8 +606,8 @@ class TestCenterCropGen3D(RandomGeneratorBaseTests):).repeat(2, 1, 1),)assert res.keys() == expected.keys()- assert_allclose(res['src'].to(device=device), expected['src'], atol=1e-4, rtol=1e-4)- assert_allclose(res['dst'].to(device=device), expected['dst'], atol=1e-4, rtol=1e-4)+ assert_close(res['src'].to(device=device), expected['src'], atol=1e-4, rtol=1e-4)+ assert_close(res['dst'].to(device=device), expected['dst'], atol=1e-4, rtol=1e-4)def test_same_on_batch(self, device, dtype):pass@@ -666,9 +666,9 @@ class TestRandomMotionBlur3D(RandomGeneratorBaseTests):direction_factor=torch.tensor([-0.4869, 0.5873], device=device, dtype=dtype),)assert res.keys() == expected.keys()- assert_allclose(res['ksize_factor'], expected['ksize_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(res['angle_factor'], expected['angle_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(res['direction_factor'], expected['direction_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['ksize_factor'], expected['ksize_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['angle_factor'], expected['angle_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['direction_factor'], expected['direction_factor'], rtol=1e-4, atol=1e-4)def test_same_on_batch(self, device, dtype):torch.manual_seed(42)@@ -689,6 +689,6 @@ class TestRandomMotionBlur3D(RandomGeneratorBaseTests):direction_factor=torch.tensor([0.9186, 0.9186], device=device, dtype=dtype),)assert res.keys() == expected.keys()- assert_allclose(res['ksize_factor'], expected['ksize_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(res['angle_factor'], expected['angle_factor'], rtol=1e-4, atol=1e-4)- assert_allclose(res['direction_factor'], expected['direction_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['ksize_factor'], expected['ksize_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['angle_factor'], expected['angle_factor'], rtol=1e-4, atol=1e-4)+ assert_close(res['direction_factor'], expected['direction_factor'], rtol=1e-4, atol=1e-4)diff --git a/test/color/test_gray.py b/test/color/test_gray.pyindex e9a835372..2c2347d68 100644--- a/test/color/test_gray.py+++ b/test/color/test_gray.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniafrom kornia.testing import BaseTester # test utils+from kornia.testing import assert_closeclass TestRgbToGrayscale(BaseTester):@@ -84,7 +84,7 @@ class TestRgbToGrayscale(BaseTester):)img_gray = kornia.rgb_to_grayscale(data)- assert_allclose(img_gray, expected)+ assert_close(img_gray, expected)def test_custom_rgb_weights(self, device, dtype):B, C, H, W = 2, 3, 4, 4@@ -107,7 +107,7 @@ class TestRgbToGrayscale(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.rgb_to_grayscaleop_jit = kornia.jit.rgb_to_grayscale- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -115,7 +115,7 @@ class TestRgbToGrayscale(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)gray_ops = kornia.color.RgbToGrayscale().to(device, dtype)gray_fcn = kornia.color.rgb_to_grayscale- assert_allclose(gray_ops(img), gray_fcn(img))+ assert_close(gray_ops(img), gray_fcn(img))class TestBgrToGrayscale(BaseTester):@@ -186,7 +186,7 @@ class TestBgrToGrayscale(BaseTester):)img_gray = kornia.bgr_to_grayscale(data)- assert_allclose(img_gray, expected)+ assert_close(img_gray, expected)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -200,7 +200,7 @@ class TestBgrToGrayscale(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.rgb_to_grayscaleop_jit = kornia.jit.bgr_to_grayscale- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -208,4 +208,4 @@ class TestBgrToGrayscale(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)gray_ops = kornia.color.BgrToGrayscale().to(device, dtype)gray_fcn = kornia.color.bgr_to_grayscale- assert_allclose(gray_ops(img), gray_fcn(img))+ assert_close(gray_ops(img), gray_fcn(img))diff --git a/test/color/test_hls.py b/test/color/test_hls.pyindex 339592953..6de9acd50 100644--- a/test/color/test_hls.py+++ b/test/color/test_hls.py@@ -3,10 +3,9 @@ import mathimport pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia-from kornia.testing import BaseTester+from kornia.testing import assert_close, BaseTesterclass TestRgbToHls(BaseTester):@@ -90,7 +89,7 @@ class TestRgbToHls(BaseTester):dtype=dtype,)- assert_allclose(kornia.color.rgb_to_hls(data), expected)+ assert_close(kornia.color.rgb_to_hls(data), expected)def test_nan_rgb_to_hls(self, device, dtype):data = torch.ones(2, 3, 5, 5, device=device, dtype=dtype)@@ -105,7 +104,7 @@ class TestRgbToHls(BaseTester):dim=1,)- assert_allclose(kornia.color.rgb_to_hls(data), expected)+ assert_close(kornia.color.rgb_to_hls(data), expected)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -119,7 +118,7 @@ class TestRgbToHls(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.rgb_to_hlsop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -127,7 +126,7 @@ class TestRgbToHls(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.RgbToHls().to(device, dtype)fcn = kornia.color.rgb_to_hls- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))class TestHlsToRgb(BaseTester):@@ -218,13 +217,13 @@ class TestHlsToRgb(BaseTester):)f = kornia.color.hls_to_rgb- assert_allclose(f(data), expected)+ assert_close(f(data), expected)data[:, 0] += 2 * math.pi- assert_allclose(f(data), expected)+ assert_close(f(data), expected)data[:, 0] -= 4 * math.pi- assert_allclose(f(data), expected)+ assert_close(f(data), expected)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -238,7 +237,7 @@ class TestHlsToRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.hls_to_rgbop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -246,4 +245,4 @@ class TestHlsToRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.HlsToRgb().to(device, dtype)fcn = kornia.color.hls_to_rgb- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))diff --git a/test/color/test_hsv.py b/test/color/test_hsv.pyindex 409d2f032..feb82e312 100644--- a/test/color/test_hsv.py+++ b/test/color/test_hsv.py@@ -3,10 +3,9 @@ import mathimport pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia-from kornia.testing import BaseTester+from kornia.testing import assert_close, BaseTesterclass TestRgbToHsv(BaseTester):@@ -90,14 +89,14 @@ class TestRgbToHsv(BaseTester):dtype=dtype,)- assert_allclose(kornia.color.rgb_to_hsv(data), expected)+ assert_close(kornia.color.rgb_to_hsv(data), expected)def test_nan_rgb_to_hsv(self, device, dtype):data = torch.zeros(1, 5, 5, device=device, dtype=dtype) # 3x5x5data = data.repeat(3, 1, 1) # 2x3x5x5expected = torch.zeros_like(data) # 3x5x5- assert_allclose(kornia.color.rgb_to_hsv(data), expected)+ assert_close(kornia.color.rgb_to_hsv(data), expected)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -111,7 +110,7 @@ class TestRgbToHsv(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.rgb_to_hsvop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -119,7 +118,7 @@ class TestRgbToHsv(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.RgbToHsv().to(device, dtype)fcn = kornia.color.rgb_to_hsv- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))class TestHsvToRgb(BaseTester):@@ -208,13 +207,13 @@ class TestHsvToRgb(BaseTester):)f = kornia.color.hsv_to_rgb- assert_allclose(f(data), expected)+ assert_close(f(data), expected)data[:, 0] += 2 * math.pi- assert_allclose(f(data), expected)+ assert_close(f(data), expected)data[:, 0] -= 4 * math.pi- assert_allclose(f(data), expected)+ assert_close(f(data), expected)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -228,7 +227,7 @@ class TestHsvToRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.hsv_to_rgbop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -236,4 +235,4 @@ class TestHsvToRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.HsvToRgb().to(device, dtype)fcn = kornia.color.hsv_to_rgb- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))diff --git a/test/color/test_lab.py b/test/color/test_lab.pyindex 81e194e89..b9254497d 100644--- a/test/color/test_lab.py+++ b/test/color/test_lab.py@@ -1,11 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils-from kornia.testing import BaseTester+from kornia.testing import assert_close, BaseTesterclass TestRgbToLab(BaseTester):@@ -84,7 +83,7 @@ class TestRgbToLab(BaseTester):)tol_val: float = utils._get_precision_by_name(device, 'xla', 1e-1, 1e-4)- assert_allclose(kornia.color.rgb_to_lab(data), expected, rtol=tol_val, atol=tol_val)+ assert_close(kornia.color.rgb_to_lab(data), expected, rtol=tol_val, atol=tol_val)def test_forth_and_back(self, device, dtype):data = torch.rand(3, 4, 5, device=device, dtype=dtype)@@ -93,7 +92,7 @@ class TestRgbToLab(BaseTester):data_out = lab(rgb(data, clip=False))tol_val: float = utils._get_precision_by_name(device, 'xla', 1e-1, 1e-4)- assert_allclose(data_out, data, rtol=tol_val, atol=tol_val)+ assert_close(data_out, data, rtol=tol_val, atol=tol_val)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -107,7 +106,7 @@ class TestRgbToLab(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.rgb_to_labop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img), rtol=1e-3, atol=1e-3)+ assert_close(op(img), op_jit(img), rtol=1e-3, atol=1e-3)@pytest.mark.nndef test_module(self, device, dtype):@@ -115,7 +114,7 @@ class TestRgbToLab(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.RgbToLab().to(device, dtype)fcn = kornia.color.rgb_to_lab- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))class TestLabToRgb(BaseTester):@@ -225,8 +224,8 @@ class TestLabToRgb(BaseTester):)tol_val: float = utils._get_precision_by_name(device, 'xla', 1e-1, 1e-4)- assert_allclose(kornia.color.lab_to_rgb(data), expected, rtol=tol_val, atol=tol_val)- assert_allclose(kornia.color.lab_to_rgb(data, clip=False), expected_unclipped, rtol=tol_val, atol=tol_val)+ assert_close(kornia.color.lab_to_rgb(data), expected, rtol=tol_val, atol=tol_val)+ assert_close(kornia.color.lab_to_rgb(data, clip=False), expected_unclipped, rtol=tol_val, atol=tol_val)def test_forth_and_back(self, device, dtype):data = torch.rand(3, 4, 5, device=device, dtype=dtype)@@ -235,7 +234,7 @@ class TestLabToRgb(BaseTester):unclipped_data_out = rgb(lab(data), clip=False)tol_val: float = utils._get_precision_by_name(device, 'xla', 1e-1, 1e-4)- assert_allclose(unclipped_data_out, data, rtol=tol_val, atol=tol_val)+ assert_close(unclipped_data_out, data, rtol=tol_val, atol=tol_val)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -250,7 +249,7 @@ class TestLabToRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.lab_to_rgbop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -258,4 +257,4 @@ class TestLabToRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.LabToRgb().to(device, dtype)fcn = kornia.color.lab_to_rgb- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))diff --git a/test/color/test_luv.py b/test/color/test_luv.pyindex 74c84ce13..70372898b 100644--- a/test/color/test_luv.py+++ b/test/color/test_luv.py@@ -1,10 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia-from kornia.testing import _get_precision, BaseTester+from kornia.testing import _get_precision, assert_close, BaseTesterclass TestRgbToLuv(BaseTester):@@ -83,7 +82,7 @@ class TestRgbToLuv(BaseTester):)tol_val: float = _get_precision(device, dtype)- assert_allclose(kornia.color.rgb_to_luv(data), expected, rtol=tol_val, atol=tol_val)+ assert_close(kornia.color.rgb_to_luv(data), expected, rtol=tol_val, atol=tol_val)def test_forth_and_back(self, device, dtype):data = torch.rand(3, 4, 5, device=device, dtype=dtype)@@ -91,7 +90,7 @@ class TestRgbToLuv(BaseTester):rgb = kornia.color.luv_to_rgbdata_out = luv(rgb(data))- assert_allclose(data_out, data, rtol=1e-4, atol=1e-4)+ assert_close(data_out, data, rtol=1e-4, atol=1e-4)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -105,7 +104,7 @@ class TestRgbToLuv(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.rgb_to_luvop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img), rtol=1e-3, atol=1e-3)+ assert_close(op(img), op_jit(img), rtol=1e-3, atol=1e-3)@pytest.mark.nndef test_module(self, device, dtype):@@ -113,7 +112,7 @@ class TestRgbToLuv(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.RgbToLuv().to(device, dtype)fcn = kornia.color.rgb_to_luv- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))class TestLuvToRgb(BaseTester):@@ -196,7 +195,7 @@ class TestLuvToRgb(BaseTester):dtype=dtype,)- assert_allclose(kornia.color.luv_to_rgb(data), expected, rtol=1e-4, atol=1e-4)+ assert_close(kornia.color.luv_to_rgb(data), expected, rtol=1e-4, atol=1e-4)def test_forth_and_back(self, device, dtype):data = torch.rand(3, 4, 5, device=device, dtype=dtype)@@ -204,7 +203,7 @@ class TestLuvToRgb(BaseTester):rgb = kornia.color.luv_to_rgbdata_out = rgb(luv(data))- assert_allclose(data_out, data, rtol=1e-4, atol=1e-4)+ assert_close(data_out, data, rtol=1e-4, atol=1e-4)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -219,7 +218,7 @@ class TestLuvToRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.luv_to_rgbop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -227,4 +226,4 @@ class TestLuvToRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.LuvToRgb().to(device, dtype)fcn = kornia.color.luv_to_rgb- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))diff --git a/test/color/test_rgb.py b/test/color/test_rgb.pyindex 6095cd85b..d88d8dcbe 100644--- a/test/color/test_rgb.py+++ b/test/color/test_rgb.py@@ -1,10 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia-from kornia.testing import BaseTester+from kornia.testing import assert_close, BaseTesterclass TestRgbToBgr(BaseTester):@@ -45,7 +44,7 @@ class TestRgbToBgr(BaseTester):data_bgr = torch.rand(1, 3, 3, 2, device=device, dtype=dtype)data_rgb = kornia.color.bgr_to_rgb(data_bgr)data_bgr_new = kornia.color.rgb_to_bgr(data_rgb)- assert_allclose(data_bgr, data_bgr_new)+ assert_close(data_bgr, data_bgr_new)def test_unit(self, device, dtype):data = torch.tensor(@@ -57,7 +56,7 @@ class TestRgbToBgr(BaseTester):) # 3x2x2f = kornia.color.rgb_to_bgr- assert_allclose(f(data), expected)+ assert_close(f(data), expected)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -71,7 +70,7 @@ class TestRgbToBgr(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.rgb_to_bgrop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -79,7 +78,7 @@ class TestRgbToBgr(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.RgbToBgr().to(device, dtype)fcn = kornia.color.rgb_to_bgr- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))@pytest.mark.nndef test_module_bgr(self, device, dtype):@@ -87,7 +86,7 @@ class TestRgbToBgr(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.BgrToRgb().to(device, dtype)fcn = kornia.color.bgr_to_rgb- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))class TestRgbToRgba(BaseTester):@@ -141,14 +140,14 @@ class TestRgbToRgba(BaseTester):x_rgb = torch.ones(3, 4, 4, device=device, dtype=dtype)x_rgba = kornia.color.rgb_to_rgba(x_rgb, a_val)x_rgb_new = kornia.color.rgba_to_rgb(x_rgba)- assert_allclose(x_rgb, x_rgb_new)+ assert_close(x_rgb, x_rgb_new)def test_back_and_forth_bgr(self, device, dtype):a_val: float = 1.0x_bgr = torch.ones(3, 4, 4, device=device, dtype=dtype)x_rgba = kornia.color.bgr_to_rgba(x_bgr, a_val)x_bgr_new = kornia.color.rgba_to_bgr(x_rgba)- assert_allclose(x_bgr, x_bgr_new)+ assert_close(x_bgr, x_bgr_new)@pytest.mark.parametrize("aval", [0.4, 45.0])def test_unit(self, device, dtype, aval):@@ -169,7 +168,7 @@ class TestRgbToRgba(BaseTester):dtype=dtype,) # Bx4x2x2- assert_allclose(kornia.rgb_to_rgba(data, aval), expected)+ assert_close(kornia.rgb_to_rgba(data, aval), expected)@pytest.mark.parametrize("aval", [0.4, 45.0])def test_unit_aval_th(self, device, dtype, aval):@@ -191,7 +190,7 @@ class TestRgbToRgba(BaseTester):) # Bx4x2x2aval = torch.full_like(data[:, :1], aval) # Bx1xHxW- assert_allclose(kornia.rgb_to_rgba(data, aval), expected)+ assert_close(kornia.rgb_to_rgba(data, aval), expected)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -213,9 +212,9 @@ class TestRgbToRgba(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.rgb_to_rgbaop_jit = torch.jit.script(op)- assert_allclose(op(img, 1.0), op_jit(img, 1.0))+ assert_close(op(img, 1.0), op_jit(img, 1.0))aval = torch.ones(B, 1, H, W, device=device, dtype=dtype)- assert_allclose(op(img, aval), op_jit(img, aval))+ assert_close(op(img, aval), op_jit(img, aval))@pytest.mark.nndef test_module(self, device, dtype):@@ -223,7 +222,7 @@ class TestRgbToRgba(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.RgbToRgba(1.0).to(device, dtype)fcn = kornia.color.rgb_to_rgba- assert_allclose(ops(img), fcn(img, 1.0))+ assert_close(ops(img), fcn(img, 1.0))@pytest.mark.nndef test_module_bgr(self, device, dtype):@@ -231,7 +230,7 @@ class TestRgbToRgba(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.BgrToRgba(1.0).to(device, dtype)fcn = kornia.color.bgr_to_rgba- assert_allclose(ops(img), fcn(img, 1.0))+ assert_close(ops(img), fcn(img, 1.0))@pytest.mark.nndef test_module_bgra2rgb(self, device, dtype):@@ -239,7 +238,7 @@ class TestRgbToRgba(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.RgbaToRgb().to(device, dtype)fcn = kornia.color.rgba_to_rgb- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))@pytest.mark.nndef test_module_bgra2bgr(self, device, dtype):@@ -247,7 +246,7 @@ class TestRgbToRgba(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.RgbaToBgr().to(device, dtype)fcn = kornia.color.rgba_to_bgr- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))class TestLinearRgb(BaseTester):@@ -290,7 +289,7 @@ class TestLinearRgb(BaseTester):data_bgr = torch.rand(1, 3, 3, 2, device=device, dtype=dtype)data_rgb = kornia.color.rgb_to_linear_rgb(data_bgr)data_bgr_new = kornia.color.linear_rgb_to_rgb(data_rgb)- assert_allclose(data_bgr, data_bgr_new)+ assert_close(data_bgr, data_bgr_new)def test_unit(self, device, dtype):data = torch.tensor(@@ -308,7 +307,7 @@ class TestLinearRgb(BaseTester):) # 3x2x2f = kornia.color.rgb_to_linear_rgb- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_unit_linear(self, device, dtype):data = torch.tensor(@@ -326,7 +325,7 @@ class TestLinearRgb(BaseTester):) # 3x2x2f = kornia.color.linear_rgb_to_rgb- assert_allclose(f(data), expected)+ assert_close(f(data), expected)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -341,7 +340,7 @@ class TestLinearRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.rgb_to_linear_rgbop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.jitdef test_jit_linear(self, device, dtype):@@ -349,7 +348,7 @@ class TestLinearRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.linear_rgb_to_rgbop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -357,7 +356,7 @@ class TestLinearRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.RgbToLinearRgb().to(device, dtype)fcn = kornia.color.rgb_to_linear_rgb- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))@pytest.mark.nndef test_module_linear(self, device, dtype):@@ -365,4 +364,4 @@ class TestLinearRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.LinearRgbToRgb().to(device, dtype)fcn = kornia.color.linear_rgb_to_rgb- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))diff --git a/test/color/test_xyz.py b/test/color/test_xyz.pyindex 0e37e6c85..9e7a956e1 100644--- a/test/color/test_xyz.py+++ b/test/color/test_xyz.py@@ -1,10 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia-from kornia.testing import BaseTester+from kornia.testing import assert_close, BaseTesterclass TestRgbToXyz(BaseTester):@@ -86,7 +85,7 @@ class TestRgbToXyz(BaseTester):dtype=dtype,)- assert_allclose(kornia.color.rgb_to_xyz(data), expected)+ assert_close(kornia.color.rgb_to_xyz(data), expected)def test_forth_and_back(self, device, dtype):data = torch.rand(3, 4, 5, device=device, dtype=dtype)@@ -94,7 +93,7 @@ class TestRgbToXyz(BaseTester):rgb = kornia.color.xyz_to_rgbdata_out = xyz(rgb(data))- assert_allclose(data_out, data)+ assert_close(data_out, data)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -108,7 +107,7 @@ class TestRgbToXyz(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.rgb_to_xyzop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -116,7 +115,7 @@ class TestRgbToXyz(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.RgbToXyz().to(device, dtype)fcn = kornia.color.rgb_to_xyz- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))class TestXyzToRgb(BaseTester):@@ -198,7 +197,7 @@ class TestXyzToRgb(BaseTester):dtype=dtype,)- assert_allclose(kornia.color.xyz_to_rgb(data), expected, atol=1e-4, rtol=1e-4)+ assert_close(kornia.color.xyz_to_rgb(data), expected, atol=1e-4, rtol=1e-4)def test_forth_and_back(self, device, dtype):data = torch.rand(3, 4, 5, device=device, dtype=dtype)@@ -206,7 +205,7 @@ class TestXyzToRgb(BaseTester):rgb = kornia.color.xyz_to_rgbdata_out = rgb(xyz(data))- assert_allclose(data_out, data)+ assert_close(data_out, data)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -220,7 +219,7 @@ class TestXyzToRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.xyz_to_rgbop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -228,4 +227,4 @@ class TestXyzToRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.XyzToRgb().to(device, dtype)fcn = kornia.color.xyz_to_rgb- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))diff --git a/test/color/test_ycbcr.py b/test/color/test_ycbcr.pyindex 9f934f439..13d543aed 100644--- a/test/color/test_ycbcr.py+++ b/test/color/test_ycbcr.py@@ -1,10 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia-from kornia.testing import BaseTester+from kornia.testing import assert_close, BaseTesterclass TestRgbToYcbcr(BaseTester):@@ -92,7 +91,7 @@ class TestRgbToYcbcr(BaseTester):dtype=dtype,)- assert_allclose(kornia.color.rgb_to_ycbcr(data), expected, atol=1e-4, rtol=1e-4)+ assert_close(kornia.color.rgb_to_ycbcr(data), expected, atol=1e-4, rtol=1e-4)# TODO: investigate and implement me# def test_forth_and_back(self, device, dtype):@@ -110,7 +109,7 @@ class TestRgbToYcbcr(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.rgb_to_ycbcrop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -118,7 +117,7 @@ class TestRgbToYcbcr(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.RgbToYcbcr().to(device, dtype)fcn = kornia.color.rgb_to_ycbcr- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))class TestYcbcrToRgb(BaseTester):@@ -206,7 +205,7 @@ class TestYcbcrToRgb(BaseTester):dtype=dtype,)- assert_allclose(kornia.color.ycbcr_to_rgb(data), expected, atol=1e-4, rtol=1e-4)+ assert_close(kornia.color.ycbcr_to_rgb(data), expected, atol=1e-4, rtol=1e-4)# TODO: investigate and implement me# def test_forth_and_back(self, device, dtype):@@ -224,7 +223,7 @@ class TestYcbcrToRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.ycbcr_to_rgbop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -232,4 +231,4 @@ class TestYcbcrToRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.YcbcrToRgb().to(device, dtype)fcn = kornia.color.ycbcr_to_rgb- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))diff --git a/test/color/test_yuv.py b/test/color/test_yuv.pyindex e7ffaf11b..2047263dd 100644--- a/test/color/test_yuv.py+++ b/test/color/test_yuv.py@@ -1,10 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia-from kornia.testing import BaseTester+from kornia.testing import assert_close, BaseTesterclass TestRgbToYuv(BaseTester):@@ -41,7 +40,7 @@ class TestRgbToYuv(BaseTester):rgb = kornia.color.yuv_to_rgbdata_out = rgb(yuv(data))- assert_allclose(data_out, data, rtol=1e-2, atol=1e-2)+ assert_close(data_out, data, rtol=1e-2, atol=1e-2)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -55,7 +54,7 @@ class TestRgbToYuv(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.rgb_to_yuvop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -63,7 +62,7 @@ class TestRgbToYuv(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.RgbToYuv().to(device, dtype)fcn = kornia.color.rgb_to_yuv- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))class TestYuvToRgb(BaseTester):@@ -100,7 +99,7 @@ class TestYuvToRgb(BaseTester):yuv = kornia.color.rgb_to_yuvdata_out = rgb(yuv(data))- assert_allclose(data_out, data, rtol=1e-2, atol=1e-2)+ assert_close(data_out, data, rtol=1e-2, atol=1e-2)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -114,7 +113,7 @@ class TestYuvToRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.color.yuv_to_rgbop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -122,4 +121,4 @@ class TestYuvToRgb(BaseTester):img = torch.ones(B, C, H, W, device=device, dtype=dtype)ops = kornia.color.YuvToRgb().to(device, dtype)fcn = kornia.color.yuv_to_rgb- assert_allclose(ops(img), fcn(img))+ assert_close(ops(img), fcn(img))diff --git a/test/enhance/test_adjust.py b/test/enhance/test_adjust.pyindex 98ff3b487..2f2180e6f 100644--- a/test/enhance/test_adjust.py+++ b/test/enhance/test_adjust.py@@ -1,12 +1,11 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utilsfrom kornia.constants import pi-from kornia.testing import BaseTester, tensor_to_gradcheck_var+from kornia.testing import assert_close, BaseTester, tensor_to_gradcheck_varclass TestInvert:@@ -23,12 +22,12 @@ class TestInvert:def test_max_val_1(self, device, dtype):img = torch.ones(1, 3, 4, 4, device=device, dtype=dtype)out = kornia.enhance.invert(img, torch.tensor(1.0))- assert_allclose(out, torch.zeros_like(out))+ assert_close(out, torch.zeros_like(out))def test_max_val_255(self, device, dtype):img = 255.0 * torch.ones(1, 3, 4, 4, device=device, dtype=dtype)out = kornia.enhance.invert(img, torch.tensor(255.0))- assert_allclose(out, torch.zeros_like(out))+ assert_close(out, torch.zeros_like(out))@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -43,7 +42,7 @@ class TestInvert:img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.enhance.invertop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))@pytest.mark.nndef test_module(self, device, dtype):@@ -51,7 +50,7 @@ class TestInvert:img = torch.ones(B, C, H, W, device=device, dtype=dtype)op = kornia.enhance.invertop_mod = kornia.enhance.Invert()- assert_allclose(op(img), op_mod(img))+ assert_close(op(img), op_mod(img))class TestAdjustSaturation:@@ -65,7 +64,7 @@ class TestAdjustSaturation:expected = data.clone()f = kornia.enhance.AdjustSaturation(1.0)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_saturation_one_batch(self, device, dtype):data = torch.tensor(@@ -79,7 +78,7 @@ class TestAdjustSaturation:expected = dataf = kornia.enhance.AdjustSaturation(torch.ones(2))- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_gradcheck(self, device, dtype):batch_size, channels, height, width = 2, 3, 4, 5@@ -99,7 +98,7 @@ class TestAdjustHue:expected = data.clone()f = kornia.enhance.AdjustHue(0.0)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_hue_one_batch(self, device, dtype):data = torch.tensor(@@ -113,7 +112,7 @@ class TestAdjustHue:expected = dataf = kornia.enhance.AdjustHue(torch.tensor([0, 0]))- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_hue_flip_batch(self, device, dtype):data = torch.tensor(@@ -129,7 +128,7 @@ class TestAdjustHue:f = kornia.enhance.AdjustHue(pi_t)result = f(data)- assert_allclose(result, result.flip(0))+ assert_close(result, result.flip(0))def test_gradcheck(self, device, dtype):batch_size, channels, height, width = 2, 3, 4, 5@@ -149,7 +148,7 @@ class TestAdjustGamma:expected = torch.ones_like(data)f = kornia.enhance.AdjustGamma(0.0)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_gamma_one(self, device, dtype):data = torch.tensor(@@ -161,7 +160,7 @@ class TestAdjustGamma:expected = data.clone()f = kornia.enhance.AdjustGamma(1.0)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_gamma_one_gain_two(self, device, dtype):data = torch.tensor(@@ -175,7 +174,7 @@ class TestAdjustGamma:) # 3x2x2f = kornia.enhance.AdjustGamma(1.0, 2.0)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_gamma_two(self, device, dtype):data = torch.tensor(@@ -191,7 +190,7 @@ class TestAdjustGamma:) # 3x2x2f = kornia.enhance.AdjustGamma(2.0)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_gamma_two_batch(self, device, dtype):data = torch.tensor(@@ -216,7 +215,7 @@ class TestAdjustGamma:p2 = torch.ones(2, device=device, dtype=dtype)f = kornia.enhance.AdjustGamma(p1, gain=p2)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_gradcheck(self, device, dtype):batch_size, channels, height, width = 2, 3, 4, 5@@ -237,7 +236,7 @@ class TestAdjustContrast:expected = torch.zeros_like(data)f = kornia.enhance.AdjustContrast(0.0)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_factor_one(self, device, dtype):# prepare input data@@ -250,7 +249,7 @@ class TestAdjustContrast:expected = data.clone()f = kornia.enhance.AdjustContrast(1.0)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_factor_two(self, device, dtype):# prepare input data@@ -265,7 +264,7 @@ class TestAdjustContrast:) # 3x2x2f = kornia.enhance.AdjustContrast(2.0)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_factor_tensor(self, device, dtype):# prepare input data@@ -294,7 +293,7 @@ class TestAdjustContrast:factor = torch.tensor([0, 1, 1.5, 2], device=device, dtype=dtype)f = kornia.enhance.AdjustContrast(factor)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_factor_tensor_color(self, device, dtype):# prepare input data@@ -319,7 +318,7 @@ class TestAdjustContrast:factor = torch.tensor([1, 2], device=device, dtype=dtype)f = kornia.enhance.AdjustContrast(factor)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_factor_tensor_shape(self, device, dtype):# prepare input data@@ -360,7 +359,7 @@ class TestAdjustContrast:factor = torch.tensor([1.5, 2.0], device=device, dtype=dtype)f = kornia.enhance.AdjustContrast(factor)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_gradcheck(self, device, dtype):batch_size, channels, height, width = 2, 3, 4, 5@@ -381,7 +380,7 @@ class TestAdjustBrightness:expected = data.clone()f = kornia.enhance.AdjustBrightness(0.0)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_factor_one(self, device, dtype):# prepare input data@@ -394,7 +393,7 @@ class TestAdjustBrightness:expected = torch.ones_like(data)f = kornia.enhance.AdjustBrightness(1.0)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_factor_minus(self, device, dtype):# prepare input data@@ -411,7 +410,7 @@ class TestAdjustBrightness:) # 3x2x2f = kornia.enhance.AdjustBrightness(-0.5)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_factor_tensor(self, device, dtype):# prepare input data@@ -431,7 +430,7 @@ class TestAdjustBrightness:expected = torch.ones_like(data)f = kornia.enhance.AdjustBrightness(factor)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_factor_tensor_color(self, device, dtype):# prepare input data@@ -456,7 +455,7 @@ class TestAdjustBrightness:factor = torch.tensor([0.25, 0.1], device=device, dtype=dtype)f = kornia.enhance.AdjustBrightness(factor)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_gradcheck(self, device, dtype):batch_size, channels, height, width = 2, 3, 4, 5@@ -518,7 +517,7 @@ class TestEqualize:f = kornia.enhance.equalize- assert_allclose(f(inputs), expected, rtol=1e-4, atol=1e-4)+ assert_close(f(inputs), expected, rtol=1e-4, atol=1e-4)def test_equalize_batch(self, device, dtype):bs, channels, height, width = 2, 3, 20, 20@@ -556,7 +555,7 @@ class TestEqualize:f = kornia.enhance.equalize- assert_allclose(f(inputs), expected, atol=1e-4, rtol=1e-4)+ assert_close(f(inputs), expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):bs, channels, height, width = 1, 2, 3, 3@@ -571,7 +570,7 @@ class TestEqualize:op = kornia.enhance.equalizeop_script = torch.jit.script(op)- assert_allclose(op(inp), op_script(inp))+ assert_close(op(inp), op_script(inp))@staticmethoddef build_input(batch_size, channels, height, width, device, dtype, row=None):@@ -617,7 +616,7 @@ class TestEqualize3D:f = kornia.enhance.equalize3d- assert_allclose(f(inputs3d), expected, atol=1e-4, rtol=1e-4)+ assert_close(f(inputs3d), expected, atol=1e-4, rtol=1e-4)def test_equalize3d_batch(self, device, dtype):bs, channels, depth, height, width = 2, 3, 6, 10, 10@@ -634,7 +633,7 @@ class TestEqualize3D:f = kornia.enhance.equalize3d- assert_allclose(f(inputs3d), expected, atol=1e-4, rtol=1e-4)+ assert_close(f(inputs3d), expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):bs, channels, depth, height, width = 1, 2, 3, 4, 5@@ -649,7 +648,7 @@ class TestEqualize3D:op = kornia.enhance.equalize3dop_script = torch.jit.script(op)- assert_allclose(op(inp), op_script(inp))+ assert_close(op(inp), op_script(inp))@staticmethoddef build_input(batch_size, channels, depth, height, width, device, dtype, row=None):@@ -715,9 +714,9 @@ class TestSharpness(BaseTester):# If factor == 1, shall return original# TODO(jian): add test for this case- # assert_allclose(TestSharpness.f(inputs, 0.), inputs, rtol=1e-4, atol=1e-4)- assert_allclose(TestSharpness.f(inputs, 1.0), inputs, rtol=1e-4, atol=1e-4)- assert_allclose(TestSharpness.f(inputs, 0.8), expected, rtol=1e-4, atol=1e-4)+ # assert_close(TestSharpness.f(inputs, 0.), inputs, rtol=1e-4, atol=1e-4)+ assert_close(TestSharpness.f(inputs, 1.0), inputs, rtol=1e-4, atol=1e-4)+ assert_close(TestSharpness.f(inputs, 0.8), expected, rtol=1e-4, atol=1e-4)def test_value_batch(self, device, dtype):torch.manual_seed(0)@@ -748,10 +747,10 @@ class TestSharpness(BaseTester):# If factor == 1, shall return originaltol_val: float = utils._get_precision(device, dtype)- assert_allclose(TestSharpness.f(inputs, 1), inputs, rtol=tol_val, atol=tol_val)- assert_allclose(TestSharpness.f(inputs, torch.tensor([1.0, 1.0])), inputs, rtol=tol_val, atol=tol_val)- assert_allclose(TestSharpness.f(inputs, 0.8), expected_08, rtol=tol_val, atol=tol_val)- assert_allclose(TestSharpness.f(inputs, torch.tensor([0.8, 1.3])), expected_08_13, rtol=tol_val, atol=tol_val)+ assert_close(TestSharpness.f(inputs, 1), inputs, rtol=tol_val, atol=tol_val)+ assert_close(TestSharpness.f(inputs, torch.tensor([1.0, 1.0])), inputs, rtol=tol_val, atol=tol_val)+ assert_close(TestSharpness.f(inputs, 0.8), expected_08, rtol=tol_val, atol=tol_val)+ assert_close(TestSharpness.f(inputs, torch.tensor([0.8, 1.3])), expected_08_13, rtol=tol_val, atol=tol_val)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -767,14 +766,14 @@ class TestSharpness(BaseTester):inputs = torch.rand(2, 1, 3, 3).to(device=device, dtype=dtype)expected = op(input, 0.8)actual = op_script(input, 0.8)- assert_allclose(actual, expected)+ assert_close(actual, expected)@pytest.mark.skip(reason="Not having it yet.")@pytest.mark.nndef test_module(self, device, dtype):img = torch.ones(2, 3, 4, 4, device=device, dtype=dtype)# gray_ops = kornia.enhance.sharpness().to(device, dtype)- # assert_allclose(gray_ops(img), f(img))+ # assert_close(gray_ops(img), f(img))@pytest.mark.skipif(kornia.xla_is_available(), reason="issues with xla device")@@ -842,7 +841,7 @@ class TestSolarize(BaseTester):)# TODO(jian): precision is very bad compared to PIL- assert_allclose(TestSolarize.f(inputs, 0.5), expected, rtol=1e-2, atol=1e-2)+ assert_close(TestSolarize.f(inputs, 0.5), expected, rtol=1e-2, atol=1e-2)@pytest.mark.graddef test_gradcheck(self, device, dtype):@@ -859,7 +858,7 @@ class TestSolarize(BaseTester):inputs = torch.rand(2, 1, 3, 3).to(device=device, dtype=dtype)expected = op(input, 0.8)actual = op_script(input, 0.8)- assert_allclose(actual, expected)+ assert_close(actual, expected)# TODO: implement me@pytest.mark.skip(reason="Not having it yet.")@@ -867,7 +866,7 @@ class TestSolarize(BaseTester):def test_module(self, device, dtype):img = torch.ones(2, 3, 4, 4, device=device, dtype=dtype)# gray_ops = kornia.enhance.sharpness().to(device, dtype)- # assert_allclose(gray_ops(img), f(img))+ # assert_close(gray_ops(img), f(img))class TestPosterize(BaseTester):@@ -921,9 +920,9 @@ class TestPosterize(BaseTester):[[[[0.0, 0.50196078, 0.0], [0.0, 0.0, 0.50196078], [0.0, 0.50196078, 0.0]]]], device=device, dtype=dtype)- assert_allclose(TestPosterize.f(inputs, 1), expected)- assert_allclose(TestPosterize.f(inputs, 0), torch.zeros_like(inputs))- assert_allclose(TestPosterize.f(inputs, 8), inputs)+ assert_close(TestPosterize.f(inputs, 1), expected)+ assert_close(TestPosterize.f(inputs, 0), torch.zeros_like(inputs))+ assert_close(TestPosterize.f(inputs, 8), inputs)@pytest.mark.skip(reason="IndexError: tuple index out of range")@pytest.mark.grad@@ -941,7 +940,7 @@ class TestPosterize(BaseTester):inputs = torch.rand(2, 1, 3, 3).to(device=device, dtype=dtype)expected = op(input, 8)actual = op_script(input, 8)- assert_allclose(actual, expected)+ assert_close(actual, expected)# TODO: implement me@pytest.mark.skip(reason="Not having it yet.")@@ -949,4 +948,4 @@ class TestPosterize(BaseTester):def test_module(self, device, dtype):img = torch.ones(2, 3, 4, 4, device=device, dtype=dtype)# gray_ops = kornia.enhance.sharpness().to(device, dtype)- # assert_allclose(gray_ops(img), f(img))+ # assert_close(gray_ops(img), f(img))diff --git a/test/enhance/test_core.py b/test/enhance/test_core.pyindex 7e5b870f5..193d22131 100644--- a/test/enhance/test_core.py+++ b/test/enhance/test_core.py@@ -3,10 +3,10 @@ import randomimport pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closedef random_shape(dim, min_elem=1, max_elem=10):@@ -29,7 +29,7 @@ class TestAddWeighted:@pytest.mark.parametrize("size", [2, 3, 4, 5])def test_smoke(self, device, dtype, size):src1, src2, alpha, beta, gamma = self.get_input(device, dtype, size=3)- assert_allclose(TestAddWeighted.fcn(src1, alpha, src2, beta, gamma), src1 * alpha + src2 * beta + gamma)+ assert_close(TestAddWeighted.fcn(src1, alpha, src2, beta, gamma), src1 * alpha + src2 * beta + gamma)def test_jit(self, device, dtype):src1, src2, alpha, beta, gamma = self.get_input(device, dtype, size=3)@@ -38,7 +38,7 @@ class TestAddWeighted:op = TestAddWeighted.fcnop_script = torch.jit.script(op)- assert_allclose(op(*inputs), op_script(*inputs), atol=1e-4, rtol=1e-4)+ assert_close(op(*inputs), op_script(*inputs), atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("size", [2, 3])def test_gradcheck(self, size, device, dtype):@@ -54,4 +54,4 @@ class TestAddWeighted:op = TestAddWeighted.fcnop_module = kornia.enhance.AddWeighted(alpha, beta, gamma)- assert_allclose(op(*inputs), op_module(src1, src2))+ assert_close(op(*inputs), op_module(src1, src2))diff --git a/test/enhance/test_equalization.py b/test/enhance/test_equalization.pyindex a0b7009b3..d249eb566 100644--- a/test/enhance/test_equalization.py+++ b/test/enhance/test_equalization.py@@ -1,10 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allclosefrom kornia import enhance-from kornia.testing import BaseTester, tensor_to_gradcheck_var+from kornia.testing import assert_close, BaseTester, tensor_to_gradcheck_varclass TestEqualization(BaseTester):@@ -82,7 +81,7 @@ class TestEqualization(BaseTester):inp = torch.rand(batch_size, channels, height, width, device=device, dtype=dtype)op = enhance.equalize_claheop_script = torch.jit.script(op)- assert_allclose(op(inp), op_script(inp))+ assert_close(op(inp), op_script(inp))def test_module(self):# equalize_clahe is only a functiondiff --git a/test/enhance/test_histogram.py b/test/enhance/test_histogram.pyindex 212a4d06c..bd7594def 100644--- a/test/enhance/test_histogram.py+++ b/test/enhance/test_histogram.py@@ -1,9 +1,9 @@import torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestHistogram:@@ -42,7 +42,7 @@ class TestHistogram:op = TestHistogram.fcnop_script = torch.jit.script(op)- assert_allclose(op(*inputs), op_script(*inputs))+ assert_close(op(*inputs), op_script(*inputs))def test_uniform_dist(self, device, dtype):input1 = torch.linspace(0, 255, 10, device=device, dtype=dtype).unsqueeze(0)@@ -51,7 +51,7 @@ class TestHistogram:pdf = TestHistogram.fcn(input1, input2, bandwidth)ans = 0.1 * torch.ones(1, 10, device=device, dtype=dtype)- assert_allclose(ans, pdf)+ assert_close(ans, pdf)class TestHistogram2d:@@ -95,7 +95,7 @@ class TestHistogram2d:op = TestHistogram2d.fcnop_script = torch.jit.script(op)- assert_allclose(op(*inputs), op_script(*inputs))+ assert_close(op(*inputs), op_script(*inputs))def test_uniform_dist(self, device, dtype):input1 = torch.linspace(0, 255, 10, device=device, dtype=dtype).unsqueeze(0)@@ -105,4 +105,4 @@ class TestHistogram2d:pdf = TestHistogram2d.fcn(input1, input2, bins, bandwidth)ans = 0.1 * kornia.eye_like(10, pdf)- assert_allclose(ans, pdf)+ assert_close(ans, pdf)diff --git a/test/enhance/test_normalize.py b/test/enhance/test_normalize.pyindex 0a8308557..95a433080 100644--- a/test/enhance/test_normalize.py+++ b/test/enhance/test_normalize.py@@ -1,11 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils-from kornia.testing import BaseTester+from kornia.testing import assert_close, BaseTesterclass TestNormalize:@@ -26,7 +25,7 @@ class TestNormalize:expected = torch.tensor([0.25], device=device, dtype=dtype).repeat(1, 2, 2).view_as(data)f = kornia.enhance.Normalize(mean, std)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_broadcast_normalize(self, device, dtype):@@ -41,7 +40,7 @@ class TestNormalize:expected = torch.ones_like(data) + 1f = kornia.enhance.Normalize(mean, std)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_float_input(self, device, dtype):@@ -55,7 +54,7 @@ class TestNormalize:expected = torch.ones_like(data) + 1f = kornia.enhance.Normalize(mean, std)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_batch_normalize(self, device, dtype):@@ -70,7 +69,7 @@ class TestNormalize:expected = torch.tensor([1.25, 1, 0.5], device=device, dtype=dtype).repeat(2, 1, 1).view_as(data)f = kornia.enhance.Normalize(mean, std)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)@pytest.mark.skip(reason="union type not supported")def test_jit(self, device, dtype):@@ -82,7 +81,7 @@ class TestNormalize:op = kornia.enhance.normalizeop_script = torch.jit.script(op)- assert_allclose(op(*inputs), op_script(*inputs))+ assert_close(op(*inputs), op_script(*inputs))def test_gradcheck(self, device, dtype):# prepare input data@@ -105,7 +104,7 @@ class TestNormalize:# expected outputexpected = (data - mean) / std- assert_allclose(kornia.normalize(data, mean, std), expected)+ assert_close(kornia.normalize(data, mean, std), expected)def test_module(self, device, dtype):data = torch.ones(2, 3, 1, 1, device=device, dtype=dtype)@@ -116,7 +115,7 @@ class TestNormalize:op = kornia.enhance.normalizeop_module = kornia.enhance.Normalize(mean, std)- assert_allclose(op(*inputs), op_module(data))+ assert_close(op(*inputs), op_module(data))class TestDenormalize:@@ -137,7 +136,7 @@ class TestDenormalize:expected = torch.tensor([2.5], device=device, dtype=dtype).repeat(1, 2, 2).view_as(data)f = kornia.enhance.Denormalize(mean, std)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_broadcast_denormalize(self, device, dtype):@@ -152,7 +151,7 @@ class TestDenormalize:expected = torch.ones_like(data) + 2.5f = kornia.enhance.Denormalize(mean, std)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_float_input(self, device, dtype):@@ -166,7 +165,7 @@ class TestDenormalize:expected = torch.ones_like(data) + 2.5f = kornia.enhance.Denormalize(mean, std)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)def test_batch_denormalize(self, device, dtype):@@ -181,7 +180,7 @@ class TestDenormalize:expected = torch.tensor([6.5, 7, 8], device=device, dtype=dtype).repeat(2, 1, 1).view_as(data)f = kornia.enhance.Denormalize(mean, std)- assert_allclose(f(data), expected)+ assert_close(f(data), expected)@pytest.mark.skip(reason="union type not supported")def test_jit(self, device, dtype):@@ -193,7 +192,7 @@ class TestDenormalize:op = kornia.enhance.denormalizeop_script = torch.jit.script(op)- assert_allclose(op(*inputs), op_script(*inputs))+ assert_close(op(*inputs), op_script(*inputs))def test_gradcheck(self, device, dtype):@@ -219,7 +218,7 @@ class TestDenormalize:# expected outputexpected = (data * std) + mean- assert_allclose(kornia.denormalize(data, mean, std), expected)+ assert_close(kornia.denormalize(data, mean, std), expected)def test_module(self, device, dtype):data = torch.ones(2, 3, 1, 1, device=device, dtype=dtype)@@ -230,7 +229,7 @@ class TestDenormalize:op = kornia.enhance.denormalizeop_module = kornia.enhance.Denormalize(mean, std)- assert_allclose(op(*inputs), op_module(data))+ assert_close(op(*inputs), op_module(data))class TestNormalizeMinMax(BaseTester):@@ -259,8 +258,8 @@ class TestNormalizeMinMax(BaseTester):def test_range(self, device, dtype, min_val, max_val):x = torch.rand(1, 2, 4, 5, device=device, dtype=dtype)out = kornia.normalize_min_max(x, min_val=min_val, max_val=max_val)- assert_allclose(out.min().item(), min_val)- assert_allclose(out.max().item(), max_val)+ assert_close(out.min().item(), min_val)+ assert_close(out.max().item(), max_val)def test_values(self, device, dtype):x = torch.tensor([[[[0.0, 1.0, 3.0], [-1.0, 4.0, 3.0], [9.0, 5.0, 2.0]]]], device=device, dtype=dtype)@@ -270,14 +269,14 @@ class TestNormalizeMinMax(BaseTester):)actual = kornia.normalize_min_max(x, min_val=-1.0, max_val=1.0)- assert_allclose(actual, expected, atol=1e-6, rtol=1e-6)+ assert_close(actual, expected, atol=1e-6, rtol=1e-6)@pytest.mark.jitdef test_jit(self, device, dtype):x = torch.ones(1, 1, 1, 1, device=device, dtype=dtype)op = kornia.normalize_min_maxop_jit = torch.jit.script(op)- assert_allclose(op(x), op_jit(x))+ assert_close(op(x), op_jit(x))@pytest.mark.graddef test_gradcheck(self, device, dtype):diff --git a/test/enhance/test_zca.py b/test/enhance/test_zca.pyindex c479a0fd1..445e044f6 100644--- a/test/enhance/test_zca.py+++ b/test/enhance/test_zca.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestZCA:@@ -25,7 +25,7 @@ class TestZCA:actual = zca(data)tol_val: float = utils._get_precision(device, dtype)- assert_allclose(actual, expected, rtol=tol_val, atol=tol_val)+ assert_close(actual, expected, rtol=tol_val, atol=tol_val)@pytest.mark.parametrize("dim", [0, 1])def test_dim_args(self, dim, device, dtype):@@ -54,7 +54,7 @@ class TestZCA:actual = zca(data, True)tol_val: float = utils._get_precision(device, dtype)- assert_allclose(actual, expected, rtol=tol_val, atol=tol_val)+ assert_close(actual, expected, rtol=tol_val, atol=tol_val)@pytest.mark.parametrize("input_shape,eps", [((15, 2, 2, 2), 1e-6), ((10, 4), 0.1), ((20, 3, 2, 2), 1e-3)])def test_identity(self, input_shape, eps, device, dtype):@@ -73,7 +73,7 @@ class TestZCA:data_hat = zca.inverse_transform(data_w)tol_val: float = utils._get_precision_by_name(device, 'xla', 1e-1, 1e-4)- assert_allclose(data, data_hat, rtol=tol_val, atol=tol_val)+ assert_close(data, data_hat, rtol=tol_val, atol=tol_val)def test_grad_zca_individual_transforms(self, device, dtype):"""@@ -144,7 +144,7 @@ class TestZCA:zca = kornia.enhance.ZCAWhitening().fit(data)zca_jit = kornia.enhance.ZCAWhitening().fit(data)zca_jit = torch.jit.script(zca_jit)- assert_allclose(zca_jit(data), zca(data))+ assert_close(zca_jit(data), zca(data))@pytest.mark.parametrize("unbiased", [True, False])def test_zca_whiten_func_unbiased(self, unbiased, device, dtype):@@ -161,4 +161,4 @@ class TestZCA:actual = kornia.zca_whiten(data, unbiased=unbiased)tol_val: float = utils._get_precision(device, dtype)- assert_allclose(actual, expected, atol=tol_val, rtol=tol_val)+ assert_close(actual, expected, atol=tol_val, rtol=tol_val)diff --git a/test/feature/test_affine_shape_estimator.py b/test/feature/test_affine_shape_estimator.pyindex 3075a2d88..9e97d95ce 100644--- a/test/feature/test_affine_shape_estimator.py+++ b/test/feature/test_affine_shape_estimator.py@@ -1,9 +1,9 @@import pytestfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia.testing as utils # test utilsfrom kornia.feature.affine_shape import *+from kornia.testing import assert_closeclass TestPatchAffineShapeEstimator:@@ -29,7 +29,7 @@ class TestPatchAffineShapeEstimator:inp[:, :, 5:-5, 1:-1] = 1abc = aff(inp)expected = torch.tensor([[[0.4146, 0.0000, 1.0000]]], device=device)- assert_allclose(abc, expected, atol=1e-4, rtol=1e-4)+ assert_close(abc, expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 1, 13, 13@@ -44,7 +44,7 @@ class TestPatchAffineShapeEstimator:patches = torch.ones(B, C, H, W, device=device, dtype=dtype)tfeat = PatchAffineShapeEstimator(W).to(patches.device, patches.dtype).eval()tfeat_jit = torch.jit.script(PatchAffineShapeEstimator(W).to(patches.device, patches.dtype).eval())- assert_allclose(tfeat_jit(patches), tfeat(patches))+ assert_close(tfeat_jit(patches), tfeat(patches))class TestLAFAffineShapeEstimator:@@ -73,7 +73,7 @@ class TestLAFAffineShapeEstimator:laf = torch.tensor([[[[20.0, 0.0, 16.0], [0.0, 20.0, 16.0]]]], device=device)new_laf = aff(laf, inp)expected = torch.tensor([[[[36.643, 0.0, 16.0], [0.0, 10.916, 16.0]]]], device=device)- assert_allclose(new_laf, expected, atol=1e-4, rtol=1e-4)+ assert_close(new_laf, expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 1, 40, 40@@ -99,7 +99,7 @@ class TestLAFAffineShapeEstimator:laf = torch.tensor([[[[20.0, 0.0, 16.0], [0.0, 20.0, 16.0]]]], device=device)tfeat = LAFAffineShapeEstimator(W).to(inp.device, inp.dtype).eval()tfeat_jit = torch.jit.script(LAFAffineShapeEstimator(W).to(inp.device, inp.dtype).eval())- assert_allclose(tfeat_jit(laf, inp), tfeat(laf, inp))+ assert_close(tfeat_jit(laf, inp), tfeat(laf, inp))class TestLAFAffNetShapeEstimator:@@ -135,7 +135,7 @@ class TestLAFAffNetShapeEstimator:laf = torch.tensor([[[[20.0, 0.0, 16.0], [0.0, 20.0, 16.0]]]], device=device)new_laf = aff(laf, inp)expected = torch.tensor([[[[40.8758, 0.0, 16.0], [-0.3824, 9.7857, 16.0]]]], device=device)- assert_allclose(new_laf, expected, atol=1e-4, rtol=1e-4)+ assert_close(new_laf, expected, atol=1e-4, rtol=1e-4)@pytest.mark.skip("jacobian not well computed")def test_gradcheck(self, device):@@ -161,4 +161,4 @@ class TestLAFAffNetShapeEstimator:laf = torch.tensor([[[[8.0, 0.0, 16.0], [0.0, 8.0, 16.0]]]], device=device)laf_estimator = LAFAffNetShapeEstimator(True).to(device, dtype=patches.dtype).eval()laf_estimator_jit = torch.jit.script(LAFAffNetShapeEstimator(True).to(device, dtype=patches.dtype).eval())- assert_allclose(laf_estimator(laf, patches), laf_estimator_jit(laf, patches))+ assert_close(laf_estimator(laf, patches), laf_estimator_jit(laf, patches))diff --git a/test/feature/test_hardnet.py b/test/feature/test_hardnet.pyindex bb0fd4780..38f4b1369 100644--- a/test/feature/test_hardnet.py+++ b/test/feature/test_hardnet.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia.testing as utils # test utilsfrom kornia.feature import HardNet, HardNet8+from kornia.testing import assert_closeclass TestHardNet:@@ -34,7 +34,7 @@ class TestHardNet:patches = torch.ones(B, C, H, W, device=device, dtype=dtype)model = HardNet().to(patches.device, patches.dtype).eval()model_jit = torch.jit.script(HardNet().to(patches.device, patches.dtype).eval())- assert_allclose(model(patches), model_jit(patches))+ assert_close(model(patches), model_jit(patches))class TestHardNet8:@@ -64,4 +64,4 @@ class TestHardNet8:patches = torch.ones(B, C, H, W, device=device, dtype=dtype)model = HardNet8().to(patches.device, patches.dtype).eval()model_jit = torch.jit.script(HardNet8().to(patches.device, patches.dtype).eval())- assert_allclose(model(patches), model_jit(patches))+ assert_close(model(patches), model_jit(patches))diff --git a/test/feature/test_laf.py b/test/feature/test_laf.pyindex 33bd10a17..d0f598cf1 100644--- a/test/feature/test_laf.py+++ b/test/feature/test_laf.py@@ -1,11 +1,11 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.geometry.transform.imgwarpimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestAngleToRotationMatrix:@@ -18,7 +18,7 @@ class TestAngleToRotationMatrix:ang_deg = torch.tensor([0, 90.0], device=device)expected = torch.tensor([[[1.0, 0.0], [0.0, 1.0]], [[0, 1.0], [-1.0, 0]]], device=device)rotmat = kornia.geometry.transform.imgwarp.angle_to_rotation_matrix(ang_deg)- assert_allclose(rotmat, expected)+ assert_close(rotmat, expected)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 2, 5, 4@@ -33,7 +33,7 @@ class TestAngleToRotationMatrix:patches = torch.rand(B, C, H, W, device=device, dtype=dtype)model = kornia.geometry.transform.imgwarp.angle_to_rotation_matrixmodel_jit = torch.jit.script(kornia.geometry.transform.imgwarp.angle_to_rotation_matrix)- assert_allclose(model(patches), model_jit(patches))+ assert_close(model(patches), model_jit(patches))class TestGetLAFScale:@@ -47,7 +47,7 @@ class TestGetLAFScale:inp = inp.view(1, 1, 2, 3)expected = torch.tensor([[[[2]]]], device=device).float()rotmat = kornia.feature.get_laf_scale(inp)- assert_allclose(rotmat, expected)+ assert_close(rotmat, expected)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 2, 2, 3@@ -61,7 +61,7 @@ class TestGetLAFScale:img = torch.rand(batch_size, channels, height, width, device=device)model = kornia.feature.get_laf_scalemodel_jit = torch.jit.script(kornia.feature.get_laf_scale)- assert_allclose(model(img), model_jit(img))+ assert_close(model(img), model_jit(img))class TestGetLAFCenter:@@ -75,7 +75,7 @@ class TestGetLAFCenter:inp = inp.view(1, 1, 2, 3)expected = torch.tensor([[[2, 3]]], device=device).float()xy = kornia.feature.get_laf_center(inp)- assert_allclose(xy, expected)+ assert_close(xy, expected)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 2, 2, 3@@ -89,7 +89,7 @@ class TestGetLAFCenter:img = torch.rand(batch_size, channels, height, width, device=device)model = kornia.feature.get_laf_centermodel_jit = torch.jit.script(kornia.feature.get_laf_center)- assert_allclose(model(img), model_jit(img))+ assert_close(model(img), model_jit(img))class TestGetLAFOri:@@ -103,7 +103,7 @@ class TestGetLAFOri:inp = inp.view(1, 1, 2, 3)expected = torch.tensor([[[45.0]]], device=device).float()angle = kornia.feature.get_laf_orientation(inp)- assert_allclose(angle, expected)+ assert_close(angle, expected)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 2, 2, 3@@ -118,7 +118,7 @@ class TestGetLAFOri:img = torch.rand(batch_size, channels, height, width, device=device)model = kornia.feature.get_laf_orientationmodel_jit = torch.jit.script(kornia.feature.get_laf_orientation)- assert_allclose(model(img), model_jit(img))+ assert_close(model(img), model_jit(img))class TestScaleLAF:@@ -138,7 +138,7 @@ class TestScaleLAF:scale = torch.tensor([[[[2.0]]]], device=device).float()out = kornia.feature.scale_laf(inp, scale)expected = torch.tensor([[[[10.0, 2, 0.8], [2, 2, -4.0]]]], device=device).float()- assert_allclose(out, expected)+ assert_close(out, expected)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 2, 2, 3@@ -156,7 +156,7 @@ class TestScaleLAF:scale = torch.rand(batch_size, device=device)model = kornia.feature.scale_lafmodel_jit = torch.jit.script(kornia.feature.scale_laf)- assert_allclose(model(laf, scale), model_jit(laf, scale))+ assert_close(model(laf, scale), model_jit(laf, scale))class TestSetLAFOri:@@ -171,7 +171,7 @@ class TestSetLAFOri:ori = torch.zeros(1, 1, 1, 1, device=device).float()out = kornia.feature.set_laf_orientation(inp, ori)expected = torch.tensor([[[[5.0, 0.0, 0.8], [0.0, 5.0, -4.0]]]], device=device).float()- assert_allclose(out, expected)+ assert_close(out, expected)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 2, 2, 3@@ -189,7 +189,7 @@ class TestSetLAFOri:ori = torch.rand(batch_size, channels, 1, 1, device=device)model = kornia.feature.set_laf_orientationmodel_jit = torch.jit.script(kornia.feature.set_laf_orientation)- assert_allclose(model(laf, ori), model_jit(laf, ori))+ assert_close(model(laf, ori), model_jit(laf, ori))class TestMakeUpright:@@ -203,20 +203,20 @@ class TestMakeUpright:inp = inp.view(1, 1, 2, 3)expected = torch.tensor([[[[1, 0, 0], [0, 1, 0]]]], device=device).float()laf = kornia.feature.make_upright(inp)- assert_allclose(laf, expected)+ assert_close(laf, expected)def test_do_nothing_with_scalea(self, device):inp = torch.tensor([[2, 0, 0], [0, 2, 0]], device=device).float()inp = inp.view(1, 1, 2, 3)expected = torch.tensor([[[[2, 0, 0], [0, 2, 0]]]], device=device).float()laf = kornia.feature.make_upright(inp)- assert_allclose(laf, expected)+ assert_close(laf, expected)def test_check_zeros(self, device):inp = torch.rand(4, 5, 2, 3, device=device)laf = kornia.feature.make_upright(inp)must_be_zeros = laf[:, :, 0, 1]- assert_allclose(must_be_zeros, torch.zeros_like(must_be_zeros))+ assert_close(must_be_zeros, torch.zeros_like(must_be_zeros))def test_gradcheck(self, device):batch_size, channels, height, width = 14, 2, 2, 3@@ -231,7 +231,7 @@ class TestMakeUpright:img = torch.rand(batch_size, channels, height, width, device=device)model = kornia.feature.make_uprightmodel_jit = torch.jit.script(kornia.feature.make_upright)- assert_allclose(model(img), model_jit(img))+ assert_close(model(img), model_jit(img))class TestELL2LAF:@@ -247,7 +247,7 @@ class TestELL2LAF:expected = torch.tensor([[10, 0, 10.0], [0, 10, -20]], device=device).float()expected = expected.view(1, 1, 2, 3)laf = kornia.feature.ellipse_to_laf(inp)- assert_allclose(laf, expected)+ assert_close(laf, expected)def test_gradcheck(self, device):batch_size, channels, height = 1, 2, 5@@ -266,7 +266,7 @@ class TestELL2LAF:img[:, :, 4] += 1.0model = kornia.feature.ellipse_to_lafmodel_jit = torch.jit.script(kornia.feature.ellipse_to_laf)- assert_allclose(model(img), model_jit(img))+ assert_close(model(img), model_jit(img))class TestNormalizeLAF:@@ -282,7 +282,7 @@ class TestNormalizeLAF:img = torch.rand(1, 3, h, w)expected = torch.tensor([[[[0.2, 0, 0.1], [0, 0.2, 0.2]]]]).float()lafn = kornia.feature.normalize_laf(laf, img)- assert_allclose(lafn, expected)+ assert_close(lafn, expected)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 2, 2, 3@@ -301,7 +301,7 @@ class TestNormalizeLAF:img = torch.rand(batch_size, 3, 10, 32)model = kornia.feature.normalize_lafmodel_jit = torch.jit.script(kornia.feature.normalize_laf)- assert_allclose(model(laf, img), model_jit(laf, img))+ assert_close(model(laf, img), model_jit(laf, img))class TestLAF2pts:@@ -316,7 +316,7 @@ class TestLAF2pts:n_pts = 6expected = torch.tensor([[[[1, 1], [1, 2], [2, 1], [1, 0], [0, 1], [1, 2]]]], device=device).float()pts = kornia.feature.laf_to_boundary_points(laf, n_pts)- assert_allclose(pts, expected)+ assert_close(pts, expected)def test_gradcheck(self, device):batch_size, channels, height, width = 3, 2, 2, 3@@ -330,7 +330,7 @@ class TestLAF2pts:laf = torch.rand(batch_size, channels, height, width, device=device)model = kornia.feature.laf_to_boundary_pointsmodel_jit = torch.jit.script(kornia.feature.laf_to_boundary_points)- assert_allclose(model(laf), model_jit(laf))+ assert_close(model(laf), model_jit(laf))class TestDenormalizeLAF:@@ -346,7 +346,7 @@ class TestDenormalizeLAF:img = torch.rand(1, 3, h, w, device=device)lafn = torch.tensor([[0.2, 0, 0.1], [0, 0.2, 0.2]], device=device).float()laf = kornia.feature.denormalize_laf(lafn.view(1, 1, 2, 3), img)- assert_allclose(laf, expected)+ assert_close(laf, expected)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 2, 2, 3@@ -365,7 +365,7 @@ class TestDenormalizeLAF:img = torch.rand(batch_size, 3, 10, 32)model = kornia.feature.denormalize_lafmodel_jit = torch.jit.script(kornia.feature.denormalize_laf)- assert_allclose(model(laf, img), model_jit(laf, img))+ assert_close(model(laf, img), model_jit(laf, img))class TestGenPatchGrid:@@ -449,7 +449,7 @@ class TestLAFIsTouchingBoundary:laf = torch.tensor([[[[10, 0, 3], [0, 10, 3]], [[1, 0, 5], [0, 1, 2]]]], device=device).float()model = kornia.feature.laf_is_inside_imagemodel_jit = torch.jit.script(kornia.feature.laf_is_inside_image)- assert_allclose(model(laf, img), model_jit(laf, img))+ assert_close(model(laf, img), model_jit(laf, img))class TestGetCreateLAF:@@ -466,7 +466,7 @@ class TestGetCreateLAF:scale = 5 * torch.ones(1, 1, 1, 1, device=device)expected = torch.tensor([[[[5, 0, 1], [0, 5, 1]]]], device=device).float()laf = kornia.feature.laf_from_center_scale_ori(xy, scale, ori)- assert_allclose(laf, expected)+ assert_close(laf, expected)def test_cross_consistency(self, device):batch_size, channels = 3, 2@@ -475,11 +475,11 @@ class TestGetCreateLAF:scale = torch.abs(torch.rand(batch_size, channels, 1, 1, device=device))laf = kornia.feature.laf_from_center_scale_ori(xy, scale, ori)scale2 = kornia.feature.get_laf_scale(laf)- assert_allclose(scale, scale2)+ assert_close(scale, scale2)xy2 = kornia.feature.get_laf_center(laf)- assert_allclose(xy2, xy)+ assert_close(xy2, xy)ori2 = kornia.feature.get_laf_orientation(laf)- assert_allclose(ori2, ori)+ assert_close(ori2, ori)def test_gradcheck(self, device):batch_size, channels = 3, 2@@ -497,7 +497,7 @@ class TestGetCreateLAF:scale = torch.abs(torch.rand(batch_size, channels, 1, 1, device=device))model = kornia.feature.laf_from_center_scale_orimodel_jit = torch.jit.script(kornia.feature.laf_from_center_scale_ori)- assert_allclose(model(xy, scale, ori), model_jit(xy, scale, ori))+ assert_close(model(xy, scale, ori), model_jit(xy, scale, ori))class TestGetLAF3pts:@@ -515,7 +515,7 @@ class TestGetLAF3pts:inp = torch.tensor([[1, 0, 2], [0, 1, 3]], device=device).float().view(1, 1, 2, 3)expected = torch.tensor([[3, 2, 2], [3, 4, 3]], device=device).float().view(1, 1, 2, 3)threepts = kornia.feature.laf_to_three_points(inp)- assert_allclose(threepts, expected)+ assert_close(threepts, expected)def test_gradcheck(self, device):batch_size, channels, height, width = 3, 2, 2, 3@@ -529,7 +529,7 @@ class TestGetLAF3pts:inp = torch.rand(batch_size, channels, height, width, device=device)model = kornia.feature.laf_to_three_pointsmodel_jit = torch.jit.script(kornia.feature.laf_to_three_points)- assert_allclose(model(inp), model_jit(inp))+ assert_close(model(inp), model_jit(inp))class TestGetLAFFrom3pts:@@ -547,14 +547,14 @@ class TestGetLAFFrom3pts:expected = torch.tensor([[1, 0, 2], [0, 1, 3]], device=device).float().view(1, 1, 2, 3)inp = torch.tensor([[3, 2, 2], [3, 4, 3]], device=device).float().view(1, 1, 2, 3)threepts = kornia.feature.laf_from_three_points(inp)- assert_allclose(threepts, expected)+ assert_close(threepts, expected)def test_cross_consistency(self, device):batch_size, channels, height, width = 3, 2, 2, 3inp = torch.rand(batch_size, channels, height, width, device=device)inp_2 = kornia.feature.laf_from_three_points(inp)inp_2 = kornia.feature.laf_to_three_points(inp_2)- assert_allclose(inp_2, inp)+ assert_close(inp_2, inp)def test_gradcheck(self, device):batch_size, channels, height, width = 3, 2, 2, 3@@ -568,4 +568,4 @@ class TestGetLAFFrom3pts:inp = torch.rand(batch_size, channels, height, width, device=device)model = kornia.feature.laf_from_three_pointsmodel_jit = torch.jit.script(kornia.feature.laf_from_three_points)- assert_allclose(model(inp), model_jit(inp))+ assert_close(model(inp), model_jit(inp))diff --git a/test/feature/test_local_features_orientation.py b/test/feature/test_local_features_orientation.pyindex fc3984838..f22b99704 100644--- a/test/feature/test_local_features_orientation.py+++ b/test/feature/test_local_features_orientation.py@@ -1,10 +1,10 @@import pytestfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utilsfrom kornia.feature.orientation import *+from kornia.testing import assert_closeclass TestPassLAF:@@ -31,7 +31,7 @@ class TestPassLAF:laf = torch.rand(1, 1, 2, 3, device=device)ori = PassLAF().to(device)out = ori(laf, inp)- assert_allclose(out, laf)+ assert_close(out, laf)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 1, 21, 21@@ -64,7 +64,7 @@ class TestPatchDominantGradientOrientation:inp[:, :, :10, :] = 1ang = ori(inp)expected = torch.tensor([90.0], device=device)- assert_allclose(kornia.rad2deg(ang), expected)+ assert_close(kornia.rad2deg(ang), expected)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 1, 13, 13@@ -80,7 +80,7 @@ class TestPatchDominantGradientOrientation:patches = torch.ones(B, C, H, W, device=device, dtype=dtype)model = PatchDominantGradientOrientation(13).to(patches.device, patches.dtype).eval()model_jit = torch.jit.script(PatchDominantGradientOrientation(13).to(patches.device, patches.dtype).eval())- assert_allclose(model(patches), model_jit(patches))+ assert_close(model(patches), model_jit(patches))class TestOriNet:@@ -112,7 +112,7 @@ class TestOriNet:ori = OriNet(True).to(device=device, dtype=inp.dtype).eval()ang = ori(inp)expected = torch.tensor([70.58], device=device)- assert_allclose(kornia.rad2deg(ang), expected, atol=1e-2, rtol=1e-3)+ assert_close(kornia.rad2deg(ang), expected, atol=1e-2, rtol=1e-3)@pytest.mark.skip("jacobian not well computed")def test_gradcheck(self, device):@@ -128,7 +128,7 @@ class TestOriNet:patches = torch.ones(B, C, H, W, device=device, dtype=dtype)tfeat = OriNet(True).to(patches.device, patches.dtype).eval()tfeat_jit = torch.jit.script(OriNet(True).to(patches.device, patches.dtype).eval())- assert_allclose(tfeat_jit(patches), tfeat(patches))+ assert_close(tfeat_jit(patches), tfeat(patches))class TestLAFOrienter:@@ -157,7 +157,7 @@ class TestLAFOrienter:laf = torch.tensor([[[[0, 5.0, 8.0], [5.0, 0.0, 8.0]]]], device=device)new_laf = ori(laf, inp)expected = torch.tensor([[[[0.0, 5.0, 8.0], [-5.0, 0, 8.0]]]], device=device)- assert_allclose(new_laf, expected)+ assert_close(new_laf, expected)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 1, 21, 21diff --git a/test/feature/test_matching.py b/test/feature/test_matching.pyindex c70dcbc31..585cb6776 100644--- a/test/feature/test_matching.py+++ b/test/feature/test_matching.py@@ -1,9 +1,9 @@import pytestfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia.testing as utils # test utilsfrom kornia.feature.matching import *+from kornia.testing import assert_closeclass TestMatchNN:@@ -23,8 +23,8 @@ class TestMatchNN:dists, idxs = match_nn(desc1, desc2)expected_dists = torch.tensor([0, 0, 0.5, 0, 0], device=device).view(-1, 1)expected_idx = torch.tensor([[0, 4], [1, 3], [2, 2], [3, 1], [4, 0]], device=device)- assert_allclose(dists, expected_dists)- assert_allclose(idxs, expected_idx)+ assert_close(dists, expected_dists)+ assert_close(idxs, expected_idx)def test_gradcheck(self, device):desc1 = torch.rand(5, 8, device=device)@@ -53,8 +53,8 @@ class TestMatchMNN:dists, idxs = match_mnn(desc1, desc2)expected_dists = torch.tensor([0, 0, 0.5, 0, 0], device=device).view(-1, 1)expected_idx = torch.tensor([[0, 4], [1, 3], [2, 2], [3, 1], [4, 0]], device=device)- assert_allclose(dists, expected_dists)- assert_allclose(idxs, expected_idx)+ assert_close(dists, expected_dists)+ assert_close(idxs, expected_idx)def test_gradcheck(self, device):desc1 = torch.rand(5, 8, device=device)@@ -83,8 +83,8 @@ class TestMatchSNN:dists, idxs = match_snn(desc1, desc2, 0.8)expected_dists = torch.tensor([0, 0, 0.35355339059327373, 0, 0], device=device).view(-1, 1)expected_idx = torch.tensor([[0, 4], [1, 3], [2, 2], [3, 1], [4, 0]], device=device)- assert_allclose(dists, expected_dists)- assert_allclose(idxs, expected_idx)+ assert_close(dists, expected_dists)+ assert_close(idxs, expected_idx)def test_matching2(self, device):desc1 = torch.tensor([[0, 0.0], [1, 1], [2, 2], [3, 3.0], [5, 5.0]], device=device)@@ -93,8 +93,8 @@ class TestMatchSNN:dists, idxs = match_snn(desc1, desc2, 0.1)expected_dists = torch.tensor([0.0, 0, 0, 0], device=device).view(-1, 1)expected_idx = torch.tensor([[0, 4], [1, 3], [3, 1], [4, 0]], device=device)- assert_allclose(dists, expected_dists)- assert_allclose(idxs, expected_idx)+ assert_close(dists, expected_dists)+ assert_close(idxs, expected_idx)def test_gradcheck(self, device):desc1 = torch.rand(5, 8, device=device)@@ -124,8 +124,8 @@ class TestMatchSMNN:dists, idxs = match_smnn(desc1, desc2, 0.8)expected_dists = torch.tensor([0, 0, 0.5423, 0, 0], device=device).view(-1, 1)expected_idx = torch.tensor([[0, 4], [1, 3], [2, 2], [3, 1], [4, 0]], device=device)- assert_allclose(dists, expected_dists)- assert_allclose(idxs, expected_idx)+ assert_close(dists, expected_dists)+ assert_close(idxs, expected_idx)def test_matching2(self, device):desc1 = torch.tensor([[0, 0.0], [1, 1], [2, 2], [3, 3.0], [5, 5.0]], device=device)@@ -134,8 +134,8 @@ class TestMatchSMNN:dists, idxs = match_smnn(desc1, desc2, 0.1)expected_dists = torch.tensor([0.0, 0, 0, 0], device=device).view(-1, 1)expected_idx = torch.tensor([[0, 4], [1, 3], [3, 1], [4, 0]], device=device)- assert_allclose(dists, expected_dists)- assert_allclose(idxs, expected_idx)+ assert_close(dists, expected_dists)+ assert_close(idxs, expected_idx)def test_gradcheck(self, device):desc1 = torch.rand(5, 8, device=device)diff --git a/test/feature/test_mkd.py b/test/feature/test_mkd.pyindex bb20b4007..1c8f0cc50 100644--- a/test/feature/test_mkd.py+++ b/test/feature/test_mkd.py@@ -1,9 +1,9 @@import pytestfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia.testing as utils # test utilsfrom kornia.feature.mkd import *+from kornia.testing import assert_close@pytest.mark.parametrize("ps", [5, 13, 25])@@ -49,8 +49,8 @@ class TestMKDGradients:expected_mags = expected_mags_1.unsqueeze(0).repeat(6, 1)expected_oris_1 = torch.Tensor([-pi, -pi, 0, 0, -pi, -pi]).to(device)expected_oris = expected_oris_1.unsqueeze(0).repeat(6, 1)- assert_allclose(out[0, 0, :, :], expected_mags, atol=1e-3, rtol=1e-3)- assert_allclose(out[0, 1, :, :], expected_oris, atol=1e-3, rtol=1e-3)+ assert_close(out[0, 0, :, :], expected_mags, atol=1e-3, rtol=1e-3)+ assert_close(out[0, 1, :, :], expected_oris, atol=1e-3, rtol=1e-3)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 1, 13, 13@@ -70,7 +70,7 @@ class TestMKDGradients:patches = torch.rand(B, C, H, W, device=device, dtype=dtype)model = MKDGradients().to(patches.device, patches.dtype).eval()model_jit = torch.jit.script(MKDGradients().to(patches.device, patches.dtype).eval())- assert_allclose(model(patches), model_jit(patches))+ assert_close(model(patches), model_jit(patches))class TestVonMisesKernel:@@ -105,15 +105,15 @@ class TestVonMisesKernel:vm = VonMisesKernel(patch_size=6, coeffs=[0.38214156, 0.48090413]).to(device)out = vm(patch)expected = torch.ones_like(out[0, 0, :, :]).to(device)- assert_allclose(out[0, 0, :, :], expected * 0.6182, atol=1e-3, rtol=1e-3)+ assert_close(out[0, 0, :, :], expected * 0.6182, atol=1e-3, rtol=1e-3)expected = torch.Tensor([0.3747, 0.3747, 0.3747, 0.6935, 0.6935, 0.6935]).to(device)expected = expected.unsqueeze(0).repeat(6, 1)- assert_allclose(out[0, 1, :, :], expected, atol=1e-3, rtol=1e-3)+ assert_close(out[0, 1, :, :], expected, atol=1e-3, rtol=1e-3)expected = torch.Tensor([0.5835, 0.5835, 0.5835, 0.0000, 0.0000, 0.0000]).to(device)expected = expected.unsqueeze(0).repeat(6, 1)- assert_allclose(out[0, 2, :, :], expected, atol=1e-3, rtol=1e-3)+ assert_close(out[0, 2, :, :], expected, atol=1e-3, rtol=1e-3)def test_gradcheck(self, device):batch_size, channels, ps = 1, 1, 13@@ -137,7 +137,7 @@ class TestVonMisesKernel:model_jit = torch.jit.script(VonMisesKernel(patch_size=13, coeffs=[0.38214156, 0.48090413]).to(patches.device, patches.dtype).eval()) # noqa- assert_allclose(model(patches), model_jit(patches))+ assert_close(model(patches), model_jit(patches))class TestEmbedGradients:@@ -165,8 +165,8 @@ class TestEmbedGradients:emb_grads = EmbedGradients(patch_size=6, relative=True).to(device)out = emb_grads(grads)expected = torch.ones_like(out[0, 0, :, :3]).to(device)- assert_allclose(out[0, 0, :, :3], expected * 0.3787, atol=1e-3, rtol=1e-3)- assert_allclose(out[0, 0, :, 3:], expected * 0, atol=1e-3, rtol=1e-3)+ assert_close(out[0, 0, :, :3], expected * 0.3787, atol=1e-3, rtol=1e-3)+ assert_close(out[0, 0, :, 3:], expected * 0, atol=1e-3, rtol=1e-3)# TODO: review this test implementation@pytest.mark.xfail(reason="RuntimeError: Jacobian mismatch for output 0 with respect to input 0,")@@ -190,7 +190,7 @@ class TestEmbedGradients:model_jit = torch.jit.script(EmbedGradients(patch_size=W, relative=True).to(patches.device, patches.dtype).eval()) # noqa- assert_allclose(model(patches), model_jit(patches))+ assert_close(model(patches), model_jit(patches))@pytest.mark.parametrize("kernel_type,d,ps", [('cart', 9, 9), ('polar', 25, 9), ('cart', 9, 16), ('polar', 25, 16)])@@ -233,13 +233,13 @@ class TestExplicitSpacialEncoding:out = cart_ese(inp)out_part = out[:, :9]expected = torch.zeros_like(out_part).to(device)- assert_allclose(out_part, expected, atol=1e-3, rtol=1e-3)+ assert_close(out_part, expected, atol=1e-3, rtol=1e-3)polar_ese = ExplicitSpacialEncoding(kernel_type='polar', fmap_size=6, in_dims=2).to(device)out = polar_ese(inp)out_part = out[:, :25]expected = torch.zeros_like(out_part).to(device)- assert_allclose(out_part, expected, atol=1e-3, rtol=1e-3)+ assert_close(out_part, expected, atol=1e-3, rtol=1e-3)@pytest.mark.parametrize("kernel_type", ['cart', 'polar'])def test_gradcheck(self, kernel_type, device):@@ -264,7 +264,7 @@ class TestExplicitSpacialEncoding:model_jit = torch.jit.script(ExplicitSpacialEncoding(kernel_type='cart', fmap_size=W, in_dims=2).to(patches.device, patches.dtype).eval()) # noqa- assert_allclose(model(patches), model_jit(patches))+ assert_close(model(patches), model_jit(patches))class TestWhitening:@@ -302,7 +302,7 @@ class TestWhitening:inp = torch.ones(1, 175).to(device).float()out = wh(inp)expected = torch.ones_like(inp).to(device) * 0.0756- assert_allclose(out, expected, atol=1e-3, rtol=1e-3)+ assert_close(out, expected, atol=1e-3, rtol=1e-3)def test_gradcheck(self, device):batch_size, in_dims = 1, 175@@ -324,7 +324,7 @@ class TestWhitening:model_jit = torch.jit.script(Whitening(xform='lw', whitening_model=None, in_dims=in_dims).to(patches.device, patches.dtype).eval()) # noqa- assert_allclose(model(patches), model_jit(patches))+ assert_close(model(patches), model_jit(patches))class TestMKDDescriptor:@@ -375,7 +375,7 @@ class TestMKDDescriptor:out = mkd(inp)out_part = out[0, -28:]expected = torch.zeros_like(out_part).to(device)- assert_allclose(out_part, expected, atol=1e-3, rtol=1e-3)+ assert_close(out_part, expected, atol=1e-3, rtol=1e-3)@pytest.mark.skip("Just because")@pytest.mark.parametrize("whitening", [None, 'lw', 'pca'])@@ -402,7 +402,7 @@ class TestMKDDescriptor:model_jit = torch.jit.script(MKDDescriptor(patch_size=ps, kernel_type=kt, whitening=wt).to(patches.device, patches.dtype).eval()) # noqa- assert_allclose(model(patches), model_jit(patches))+ assert_close(model(patches), model_jit(patches))class TestSimpleKD:@@ -448,4 +448,4 @@ class TestSimpleKD:model_jit = torch.jit.script(SimpleKD(patch_size=ps, kernel_type='polar', whitening='lw').to(patches.device, patches.dtype).eval()) # noqa- assert_allclose(model(patches), model_jit(patches))+ assert_close(model(patches), model_jit(patches))diff --git a/test/feature/test_nms.py b/test/feature/test_nms.pyindex 172481aca..1fcba943e 100644--- a/test/feature/test_nms.py+++ b/test/feature/test_nms.py@@ -1,9 +1,9 @@import torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestNMS2d:@@ -47,7 +47,7 @@ class TestNMS2d:).float()nms = kornia.feature.NonMaximaSuppression2d((3, 3)).to(device)scores = nms(inp)- assert_allclose(scores, expected, atol=1e-4, rtol=1e-3)+ assert_close(scores, expected, atol=1e-4, rtol=1e-3)def test_gradcheck(self, device):k = 0.04@@ -130,7 +130,7 @@ class TestNMS3d:).to(device)nms = kornia.feature.NonMaximaSuppression3d((3, 3, 3)).to(device)scores = nms(inp)- assert_allclose(scores, expected, atol=1e-4, rtol=1e-3)+ assert_close(scores, expected, atol=1e-4, rtol=1e-3)def test_gradcheck(self, device):batch_size, channels, depth, height, width = 1, 1, 4, 5, 4diff --git a/test/feature/test_responces_local_features.py b/test/feature/test_responces_local_features.pyindex 2f2936f68..b68c8d195 100644--- a/test/feature/test_responces_local_features.py+++ b/test/feature/test_responces_local_features.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestCornerHarris:@@ -54,7 +54,7 @@ class TestCornerHarris:).float()harris = kornia.feature.CornerHarris(k=0.04).to(device)scores = harris(inp)- assert_allclose(scores, expected, atol=1e-4, rtol=1e-3)+ assert_close(scores, expected, atol=1e-4, rtol=1e-3)def test_corners_batch(self, device):inp = torch.tensor(@@ -107,7 +107,7 @@ class TestCornerHarris:/ 10.0)scores = kornia.feature.harris_response(inp, k=0.04)- assert_allclose(scores, expected, atol=1e-4, rtol=1e-4)+ assert_close(scores, expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device):k = 0.04@@ -126,7 +126,7 @@ class TestCornerHarris:img = torch.rand(2, 3, 4, 5, device=device)actual = op_script(img, k)expected = kornia.feature.harris_response(img, k)- assert_allclose(actual, expected)+ assert_close(actual, expected)class TestCornerGFTT:@@ -176,7 +176,7 @@ class TestCornerGFTT:).float()shi_tomasi = kornia.feature.CornerGFTT().to(device)scores = shi_tomasi(inp)- assert_allclose(scores, expected, atol=1e-4, rtol=1e-3)+ assert_close(scores, expected, atol=1e-4, rtol=1e-3)def test_corners_batch(self, device):inp = torch.tensor(@@ -227,7 +227,7 @@ class TestCornerGFTT:).repeat(2, 1, 1, 1)shi_tomasi = kornia.feature.CornerGFTT().to(device)scores = shi_tomasi(inp)- assert_allclose(scores, expected, atol=1e-4, rtol=1e-4)+ assert_close(scores, expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 2, 5, 4@@ -244,7 +244,7 @@ class TestCornerGFTT:img = torch.rand(2, 3, 4, 5, device=device)actual = op_script(img)expected = kornia.feature.gftt_response(img)- assert_allclose(actual, expected)+ assert_close(actual, expected)class TestBlobHessian:@@ -307,7 +307,7 @@ class TestBlobHessian:).repeat(2, 1, 1, 1)shi_tomasi = kornia.feature.BlobHessian().to(device)scores = shi_tomasi(inp)- assert_allclose(scores, expected, atol=1e-4, rtol=1e-4)+ assert_close(scores, expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 2, 5, 4@@ -324,4 +324,4 @@ class TestBlobHessian:img = torch.rand(2, 3, 4, 5, device=device)actual = op_script(img)expected = kornia.feature.hessian_response(img)- assert_allclose(actual, expected)+ assert_close(actual, expected)diff --git a/test/feature/test_scale_space_detector.py b/test/feature/test_scale_space_detector.pyindex ea17f02f0..d1ab3e273 100644--- a/test/feature/test_scale_space_detector.py+++ b/test/feature/test_scale_space_detector.py@@ -1,10 +1,10 @@import pytestfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utilsfrom kornia.feature.scale_space_detector import *+from kornia.testing import assert_closeclass TestScaleSpaceDetector:@@ -36,8 +36,8 @@ class TestScaleSpaceDetector:lafs, resps = det(inp)expected_laf = torch.tensor([[[[9.5823, 0.0000, 16.0], [0.0, 9.5823, 16.0]]]], device=device)expected_resp = torch.tensor([[0.0857]], device=device)- assert_allclose(lafs, expected_laf, rtol=0.001, atol=1e-03)- assert_allclose(resps, expected_resp, rtol=0.001, atol=1e-03)+ assert_close(lafs, expected_laf, rtol=0.001, atol=1e-03)+ assert_close(resps, expected_resp, rtol=0.001, atol=1e-03)def test_toy_mask(self, device):if "cuda" in str(device):@@ -54,8 +54,8 @@ class TestScaleSpaceDetector:lafs, resps = det(inp, mask)expected_laf = torch.tensor([[[[9.5823, 0.0000, 16.0], [0.0, 9.5823, 16.0]]]], device=device)expected_resp = torch.tensor([[0.0857]], device=device)- assert_allclose(lafs, expected_laf, rtol=0.001, atol=1e-03)- assert_allclose(resps, expected_resp, rtol=0.001, atol=1e-03)+ assert_close(lafs, expected_laf, rtol=0.001, atol=1e-03)+ assert_close(resps, expected_resp, rtol=0.001, atol=1e-03)def test_gradcheck(self, device):batch_size, channels, height, width = 1, 1, 31, 21diff --git a/test/feature/test_siftdesc.py b/test/feature/test_siftdesc.pyindex 9af3f5e27..604a504e8 100644--- a/test/feature/test_siftdesc.py+++ b/test/feature/test_siftdesc.py@@ -1,9 +1,9 @@import pytestfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia.testing as utils # test utilsfrom kornia.feature.siftdesc import *+from kornia.testing import assert_close@pytest.mark.parametrize("ksize", [5, 13, 25])@@ -47,7 +47,7 @@ class TestSIFTDescriptor:sift = SIFTDescriptor(6, num_ang_bins=4, num_spatial_bins=1, clipval=0.2, rootsift=False).to(device)out = sift(patch)expected = torch.tensor([[0, 0, 1.0, 0]], device=device)- assert_allclose(out, expected, atol=1e-3, rtol=1e-3)+ assert_close(out, expected, atol=1e-3, rtol=1e-3)@pytest.mark.xfail(reason='May raise checkIfNumericalAnalyticAreClose.')def test_gradcheck(self, device):@@ -63,4 +63,4 @@ class TestSIFTDescriptor:patches = torch.ones(B, C, H, W, device=device, dtype=dtype)model = SIFTDescriptor(41).to(patches.device, patches.dtype).eval()model_jit = torch.jit.script(SIFTDescriptor(41).to(patches.device, patches.dtype).eval())- assert_allclose(model(patches), model_jit(patches))+ assert_close(model(patches), model_jit(patches))diff --git a/test/feature/test_sosnet.py b/test/feature/test_sosnet.pyindex 473dbd48b..e69d0c65b 100644--- a/test/feature/test_sosnet.py+++ b/test/feature/test_sosnet.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia.testing as utils # test utilsfrom kornia.feature import SOSNet+from kornia.testing import assert_closeclass TestSOSNet:@@ -34,4 +34,4 @@ class TestSOSNet:patches = torch.ones(B, C, H, W, device=device, dtype=dtype)model = SOSNet().to(patches.device, patches.dtype).eval()model_jit = torch.jit.script(SOSNet().to(patches.device, patches.dtype).eval())- assert_allclose(model(patches), model_jit(patches))+ assert_close(model(patches), model_jit(patches))diff --git a/test/feature/test_tfeat.py b/test/feature/test_tfeat.pyindex 97769a6f6..82464623a 100644--- a/test/feature/test_tfeat.py+++ b/test/feature/test_tfeat.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia.testing as utils # test utilsfrom kornia.feature import TFeat+from kornia.testing import assert_closeclass TestTFeat:@@ -41,4 +41,4 @@ class TestTFeat:patches = torch.ones(B, C, H, W, device=device, dtype=dtype)tfeat = TFeat(True).to(patches.device, patches.dtype).eval()tfeat_jit = torch.jit.script(TFeat(True).to(patches.device, patches.dtype).eval())- assert_allclose(tfeat_jit(patches), tfeat(patches))+ assert_close(tfeat_jit(patches), tfeat(patches))diff --git a/test/filters/test_blur.py b/test/filters/test_blur.pyindex e369776af..19edaf855 100644--- a/test/filters/test_blur.py+++ b/test/filters/test_blur.py@@ -1,9 +1,9 @@import torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestBoxBlur:@@ -38,7 +38,7 @@ class TestBoxBlur:actual = kornia.filters.box_blur(inp, kernel_size)tol_val: float = utils._get_precision_by_name(device, 'xla', 1e-1, 1e-4)- assert_allclose(actual.sum(), torch.tensor(35.0).to(actual), rtol=tol_val, atol=tol_val)+ assert_close(actual.sum(), torch.tensor(35.0).to(actual), rtol=tol_val, atol=tol_val)# TODO(dmytro): normalized does not make any effectdef test_kernel_3x3_nonormalize(self, device, dtype):@@ -62,7 +62,7 @@ class TestBoxBlur:actual = kornia.filters.box_blur(inp, kernel_size, normalized=False)tol_val: float = utils._get_precision_by_name(device, 'xla', 1e-1, 1e-4)- assert_allclose(actual.sum(), torch.tensor(35.0).to(actual), rtol=tol_val, atol=tol_val)+ assert_close(actual.sum(), torch.tensor(35.0).to(actual), rtol=tol_val, atol=tol_val)def test_kernel_5x5(self, device, dtype):inp = torch.tensor(@@ -87,7 +87,7 @@ class TestBoxBlur:actual = kornia.filters.box_blur(inp, kernel_size)tol_val: float = utils._get_precision_by_name(device, 'xla', 1e-1, 1e-4)- assert_allclose(actual[:, 0, 2, 2], expected, rtol=tol_val, atol=tol_val)+ assert_close(actual[:, 0, 2, 2], expected, rtol=tol_val, atol=tol_val)def test_kernel_5x5_batch(self, device, dtype):batch_size = 3@@ -113,7 +113,7 @@ class TestBoxBlur:actual = kornia.filters.box_blur(inp, kernel_size)tol_val: float = utils._get_precision_by_name(device, 'xla', 1e-1, 1e-4)- assert_allclose(actual[:, 0, 2, 2], expected, rtol=tol_val, atol=tol_val)+ assert_close(actual[:, 0, 2, 2], expected, rtol=tol_val, atol=tol_val)def test_noncontiguous(self, device, dtype):batch_size = 3@@ -122,7 +122,7 @@ class TestBoxBlur:kernel_size = (3, 3)actual = kornia.filters.box_blur(inp, kernel_size)expected = actual- assert_allclose(actual, actual)+ assert_close(actual, actual)def test_gradcheck(self, device, dtype):batch_size, channels, height, width = 1, 2, 5, 4@@ -138,7 +138,7 @@ class TestBoxBlur:img = torch.rand(2, 3, 4, 5, device=device, dtype=dtype)actual = op_script(img, kernel_size)expected = op(img, kernel_size)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_module(self, device, dtype):op = kornia.filters.box_blur@@ -148,4 +148,4 @@ class TestBoxBlur:img = torch.rand(2, 3, 4, 5, device=device, dtype=dtype)actual = op_module(kernel_size)(img)expected = op(img, kernel_size)- assert_allclose(actual, expected)+ assert_close(actual, expected)diff --git a/test/filters/test_blur_pool.py b/test/filters/test_blur_pool.pyindex fdddb422b..34a655598 100644--- a/test/filters/test_blur_pool.py+++ b/test/filters/test_blur_pool.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestMaxBlurPool:@@ -27,7 +27,7 @@ class TestMaxBlurPool:kernel_size = 3actual = kornia.filters.max_blur_pool2d(inp, kernel_size)expected = actual- assert_allclose(actual, actual)+ assert_close(actual, actual)def test_gradcheck(self, device, dtype):batch_size, channels, height, width = 1, 2, 5, 4@@ -43,7 +43,7 @@ class TestMaxBlurPool:img = torch.rand(2, 3, 4, 5, device=device, dtype=dtype)actual = op_script(img, kernel_size)expected = op(img, kernel_size)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_module(self, device, dtype):op = kornia.filters.max_blur_pool2d@@ -53,7 +53,7 @@ class TestMaxBlurPool:img = torch.rand(2, 3, 4, 5, device=device, dtype=dtype)actual = op_module(kernel_size)(img)expected = op(img, kernel_size)- assert_allclose(actual, expected)+ assert_close(actual, expected)class TestBlurPool:@@ -78,7 +78,7 @@ class TestBlurPool:kernel_size = 3actual = kornia.filters.blur_pool2d(inp, kernel_size)expected = actual- assert_allclose(actual, actual)+ assert_close(actual, actual)def test_gradcheck(self, device, dtype):batch_size, channels, height, width = 1, 2, 5, 4@@ -94,7 +94,7 @@ class TestBlurPool:img = torch.rand(2, 3, 4, 5, device=device, dtype=dtype)actual = op_script(img, kernel_size)expected = op(img, kernel_size)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_module(self, device, dtype):op = kornia.filters.blur_pool2d@@ -104,4 +104,4 @@ class TestBlurPool:img = torch.rand(2, 3, 4, 5, device=device, dtype=dtype)actual = op_module(kernel_size)(img)expected = op(img, kernel_size)- assert_allclose(actual, expected)+ assert_close(actual, expected)diff --git a/test/filters/test_canny.py b/test/filters/test_canny.pyindex 68310442e..88392dff9 100644--- a/test/filters/test_canny.py+++ b/test/filters/test_canny.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestCanny:@@ -93,8 +93,8 @@ class TestCanny:magnitude, edges = kornia.filters.canny(inp)tol_val: float = utils._get_precision(device, dtype)- assert_allclose(magnitude, expected_magnitude, rtol=tol_val, atol=tol_val)- assert_allclose(edges, expected_edges, rtol=tol_val, atol=tol_val)+ assert_close(magnitude, expected_magnitude, rtol=tol_val, atol=tol_val)+ assert_close(edges, expected_edges, rtol=tol_val, atol=tol_val)def test_magnitude_hyst(self, device, dtype):inp = torch.tensor(@@ -148,8 +148,8 @@ class TestCanny:magnitude, edges = kornia.filters.canny(inp, hysteresis=True)tol_val: float = utils._get_precision(device, dtype)- assert_allclose(magnitude, expected_magnitude, rtol=tol_val, atol=tol_val)- assert_allclose(edges, expected_edges, rtol=tol_val, atol=tol_val)+ assert_close(magnitude, expected_magnitude, rtol=tol_val, atol=tol_val)+ assert_close(edges, expected_edges, rtol=tol_val, atol=tol_val)def test_magnitude_hyst_false(self, device, dtype):inp = torch.tensor(@@ -203,8 +203,8 @@ class TestCanny:magnitude, edges = kornia.filters.canny(inp, hysteresis=False)tol_val: float = utils._get_precision(device, dtype)- assert_allclose(magnitude, expected_magnitude, rtol=tol_val, atol=tol_val)- assert_allclose(edges, expected_edges, rtol=tol_val, atol=tol_val)+ assert_close(magnitude, expected_magnitude, rtol=tol_val, atol=tol_val)+ assert_close(edges, expected_edges, rtol=tol_val, atol=tol_val)def test_magnitude_threshold(self, device, dtype):inp = torch.tensor(@@ -258,8 +258,8 @@ class TestCanny:magnitude, edges = kornia.filters.canny(inp, low_threshold=0.3, high_threshold=0.9)tol_val: float = utils._get_precision(device, dtype)- assert_allclose(magnitude, expected_magnitude, rtol=tol_val, atol=tol_val)- assert_allclose(edges, expected_edges, rtol=tol_val, atol=tol_val)+ assert_close(magnitude, expected_magnitude, rtol=tol_val, atol=tol_val)+ assert_close(edges, expected_edges, rtol=tol_val, atol=tol_val)def test_gradcheck(self, device, dtype):if "cuda" in str(device):@@ -275,8 +275,8 @@ class TestCanny:op_script = torch.jit.script(op)expected_magnitude, expected_edges = op(img)actual_magnitude, actual_edges = op_script(img)- assert_allclose(actual_magnitude, expected_magnitude)- assert_allclose(actual_edges, expected_edges)+ assert_close(actual_magnitude, expected_magnitude)+ assert_close(actual_edges, expected_edges)def test_module(self, device, dtype):img = torch.rand(2, 3, 4, 5, device=device, dtype=dtype)@@ -284,5 +284,5 @@ class TestCanny:op_module = kornia.filters.Canny()expected_magnitude, expected_edges = op(img)actual_magnitude, actual_edges = op(img)- assert_allclose(actual_magnitude, expected_magnitude)- assert_allclose(actual_edges, expected_edges)+ assert_close(actual_magnitude, expected_magnitude)+ assert_close(actual_edges, expected_edges)diff --git a/test/filters/test_filters.py b/test/filters/test_filters.pyindex 264df04fb..ecbbfebe0 100644--- a/test/filters/test_filters.py+++ b/test/filters/test_filters.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestFilter2D:@@ -54,7 +54,7 @@ class TestFilter2D:)actual = kornia.filter2d(input, kernel)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_mean_filter_2batch_2ch(self, device, dtype):kernel = torch.ones(1, 3, 3, device=device, dtype=dtype)@@ -91,7 +91,7 @@ class TestFilter2D:).expand(2, 2, -1, -1)actual = kornia.filter2d(input, kernel)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_normalized_mean_filter(self, device, dtype):kernel = torch.ones(1, 3, 3).to(device)@@ -131,7 +131,7 @@ class TestFilter2D:actual = kornia.filter2d(input, kernel, normalized=True)tol_val: float = utils._get_precision_by_name(device, 'xla', 1e-1, 1e-4)- assert_allclose(actual, expected, rtol=tol_val, atol=tol_val)+ assert_close(actual, expected, rtol=tol_val, atol=tol_val)def test_even_sized_filter(self, device, dtype):kernel = torch.ones(1, 2, 2, device=device, dtype=dtype)@@ -168,7 +168,7 @@ class TestFilter2D:)actual = kornia.filter2d(input, kernel)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_noncontiguous(self, device, dtype):batch_size = 3@@ -177,7 +177,7 @@ class TestFilter2D:actual = kornia.filter2d(inp, kernel)expected = actual- assert_allclose(actual, actual)+ assert_close(actual, actual)def test_gradcheck(self, device):kernel = torch.rand(1, 3, 3, device=device)@@ -196,7 +196,7 @@ class TestFilter2D:input = torch.ones(1, 1, 7, 8, device=device, dtype=dtype)expected = op(input, kernel)actual = op_script(input, kernel)- assert_allclose(actual, expected)+ assert_close(actual, expected)class TestFilter3D:@@ -279,7 +279,7 @@ class TestFilter3D:)actual = kornia.filter3d(input, kernel)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_mean_filter_2batch_2ch(self, device, dtype):kernel = torch.ones(1, 3, 3, 3, device=device, dtype=dtype)@@ -350,7 +350,7 @@ class TestFilter3D:expected = expected.expand(2, 2, -1, -1, -1)actual = kornia.filter3d(input, kernel)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_normalized_mean_filter(self, device, dtype):kernel = torch.ones(1, 3, 3, 3, device=device, dtype=dtype)@@ -424,7 +424,7 @@ class TestFilter3D:actual = kornia.filter3d(input, kernel, normalized=True)tol_val: float = utils._get_precision_by_name(device, 'xla', 1e-1, 1e-4)- assert_allclose(actual, expected, rtol=tol_val, atol=tol_val)+ assert_close(actual, expected, rtol=tol_val, atol=tol_val)def test_even_sized_filter(self, device, dtype):kernel = torch.ones(1, 2, 2, 2, device=device, dtype=dtype)@@ -493,7 +493,7 @@ class TestFilter3D:)actual = kornia.filter3d(input, kernel)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_noncontiguous(self, device, dtype):batch_size = 3@@ -502,7 +502,7 @@ class TestFilter3D:actual = kornia.filter3d(inp, kernel)expected = actual- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_gradcheck(self, device):kernel = torch.rand(1, 3, 3, 3, device=device)@@ -521,4 +521,4 @@ class TestFilter3D:input = torch.ones(1, 1, 2, 7, 8, device=device, dtype=dtype)expected = op(input, kernel)actual = op_script(input, kernel)- assert_allclose(actual, expected)+ assert_close(actual, expected)diff --git a/test/filters/test_gaussian.py b/test/filters/test_gaussian.pyindex a96a02dc3..e7222da3d 100644--- a/test/filters/test_gaussian.py+++ b/test/filters/test_gaussian.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_close@pytest.mark.parametrize("window_size", [5, 11])@@ -57,7 +57,7 @@ class TestGaussianBlur2d:kernel_size = (3, 3)sigma = (1.5, 2.1)actual = kornia.filters.gaussian_blur2d(input, kernel_size, sigma, "replicate")- assert_allclose(actual, actual)+ assert_close(actual, actual)def test_gradcheck(self, device, dtype):# test parameters@@ -76,7 +76,7 @@ class TestGaussianBlur2d:params = [(3, 3), (1.5, 1.5)]img = torch.ones(1, 3, 5, 5, device=device, dtype=dtype)- assert_allclose(op(img, *params), op_script(img, *params))+ assert_close(op(img, *params), op_script(img, *params))def test_module(self, device, dtype):params = [(3, 3), (1.5, 1.5)]@@ -84,4 +84,4 @@ class TestGaussianBlur2d:op_module = kornia.filters.GaussianBlur2d(*params)img = torch.ones(1, 3, 5, 5, device=device, dtype=dtype)- assert_allclose(op(img, *params), op_module(img))+ assert_close(op(img, *params), op_module(img))diff --git a/test/filters/test_laplacian.py b/test/filters/test_laplacian.pyindex c6d57f5c3..89801ef1d 100644--- a/test/filters/test_laplacian.py+++ b/test/filters/test_laplacian.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_close@pytest.mark.parametrize("window_size", [5])@@ -30,7 +30,7 @@ def test_get_laplacian_kernel2d(window_size):[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],])- assert_allclose(expected, kernel)+ assert_close(expected, kernel)class TestLaplacian:@@ -48,7 +48,7 @@ class TestLaplacian:kernel_size = 3actual = kornia.filters.laplacian(input, kernel_size)- assert_allclose(actual, actual)+ assert_close(actual, actual)def test_gradcheck(self, device, dtype):# test parameters@@ -66,7 +66,7 @@ class TestLaplacian:params = [3]img = torch.ones(1, 3, 5, 5, device=device, dtype=dtype)- assert_allclose(op(img, *params), op_script(img, *params))+ assert_close(op(img, *params), op_script(img, *params))def test_module(self, device, dtype):params = [3]@@ -74,4 +74,4 @@ class TestLaplacian:op_module = kornia.filters.Laplacian(*params)img = torch.ones(1, 3, 5, 5, device=device, dtype=dtype)- assert_allclose(op(img, *params), op_module(img))+ assert_close(op(img, *params), op_module(img))diff --git a/test/filters/test_median.py b/test/filters/test_median.pyindex 2869e2ac1..3445eca9d 100644--- a/test/filters/test_median.py+++ b/test/filters/test_median.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestMedianBlur:@@ -40,8 +40,8 @@ class TestMedianBlur:kernel_size = (3, 3)actual = kornia.filters.median_blur(inp, kernel_size)- assert_allclose(actual[0, 0, 2, 2], torch.tensor(3.0).to(actual))- assert_allclose(actual[0, 1, 1, 1], torch.tensor(14.0).to(actual))+ assert_close(actual[0, 0, 2, 2], torch.tensor(3.0).to(actual))+ assert_close(actual[0, 1, 1, 1], torch.tensor(14.0).to(actual))def test_noncontiguous(self, device, dtype):batch_size = 3@@ -50,7 +50,7 @@ class TestMedianBlur:kernel_size = (3, 3)actual = kornia.filters.median_blur(inp, kernel_size)expected = actual- assert_allclose(actual, actual)+ assert_close(actual, actual)@pytest.mark.xfail(reason="this tests is a bit unstable")def test_gradcheck(self, device, dtype):@@ -66,7 +66,7 @@ class TestMedianBlur:op_script = torch.jit.script(op)actual = op_script(img, kernel_size)expected = op(img, kernel_size)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_module(self, device, dtype):kernel_size = (3, 5)@@ -75,4 +75,4 @@ class TestMedianBlur:op_module = kornia.filters.MedianBlur((3, 5))actual = op_module(img)expected = op(img, kernel_size)- assert_allclose(actual, expected)+ assert_close(actual, expected)diff --git a/test/filters/test_motion.py b/test/filters/test_motion.pyindex 592f1efb6..19d9ec944 100644--- a/test/filters/test_motion.py+++ b/test/filters/test_motion.py@@ -1,11 +1,11 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.filters.kernels_geometryimport kornia.testing as utils # test utils+from kornia.testing import assert_close@pytest.mark.parametrize("batch_size", [0, 1, 5])@@ -20,7 +20,7 @@ def test_get_motion_kernel2d(batch_size, ksize, angle, direction):batch_size = 1kernel = kornia.filters.kernels_geometry.get_motion_kernel2d(ksize, angle, direction)assert kernel.shape == (batch_size, ksize, ksize)- assert_allclose(kernel.sum(), batch_size)+ assert kernel.sum().item() == pytest.approx(batch_size)class TestMotionBlur:@@ -43,7 +43,7 @@ class TestMotionBlur:direction = 0.3actual = kornia.filters.motion_blur(inp, kernel_size, angle, direction)expected = actual- assert_allclose(actual, actual)+ assert_close(actual, actual)def test_gradcheck(self, device, dtype):batch_shape = (1, 3, 4, 5)@@ -65,4 +65,4 @@ class TestMotionBlur:op_script = torch.jit.script(op)actual = op_script(img, ksize, angle, direction)expected = op(img, ksize, angle, direction)- assert_allclose(actual, expected)+ assert_close(actual, expected)diff --git a/test/filters/test_sobel.py b/test/filters/test_sobel.pyindex 05199b794..f1b336d3b 100644--- a/test/filters/test_sobel.py+++ b/test/filters/test_sobel.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestSpatialGradient:@@ -61,7 +61,7 @@ class TestSpatialGradient:)edges = kornia.filters.spatial_gradient(inp, normalized=False)- assert_allclose(edges, expected)+ assert_close(edges, expected)def test_edges_norm(self, device, dtype):inp = torch.tensor(@@ -109,7 +109,7 @@ class TestSpatialGradient:)edges = kornia.filters.spatial_gradient(inp, normalized=True)- assert_allclose(edges, expected)+ assert_close(edges, expected)def test_edges_sep(self, device, dtype):inp = torch.tensor(@@ -154,7 +154,7 @@ class TestSpatialGradient:)edges = kornia.filters.spatial_gradient(inp, 'diff', normalized=False)- assert_allclose(edges, expected)+ assert_close(edges, expected)def test_edges_sep_norm(self, device, dtype):inp = torch.tensor(@@ -202,7 +202,7 @@ class TestSpatialGradient:)edges = kornia.filters.spatial_gradient(inp, 'diff', normalized=True)- assert_allclose(edges, expected)+ assert_close(edges, expected)def test_noncontiguous(self, device, dtype):batch_size = 3@@ -226,7 +226,7 @@ class TestSpatialGradient:op_script = torch.jit.script(op)actual = op_script(img)expected = op(img)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_module(self, device, dtype):img = torch.rand(2, 3, 4, 5, device=device, dtype=dtype)@@ -234,7 +234,7 @@ class TestSpatialGradient:op_module = kornia.filters.SpatialGradient()expected = op(img)actual = op_module(img)- assert_allclose(actual, expected)+ assert_close(actual, expected)class TestSpatialGradient3d:@@ -363,7 +363,7 @@ class TestSpatialGradient3d:)edges = kornia.filters.spatial_gradient3d(inp)- assert_allclose(edges, expected)+ assert_close(edges, expected)def test_gradcheck(self, device, dtype):img = torch.rand(1, 1, 1, 3, 4, device=device, dtype=dtype)@@ -377,7 +377,7 @@ class TestSpatialGradient3d:op_script = torch.jit.script(op)expected = op(img)actual = op_script(img)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_module(self, device, dtype):img = torch.rand(2, 3, 1, 4, 5, device=device, dtype=dtype)@@ -385,7 +385,7 @@ class TestSpatialGradient3d:op_module = kornia.filters.SpatialGradient3d()expected = op(img)actual = op_module(img)- assert_allclose(actual, expected)+ assert_close(actual, expected)class TestSobel:@@ -433,7 +433,7 @@ class TestSobel:)edges = kornia.filters.sobel(inp, normalized=False, eps=0.0)- assert_allclose(edges, expected)+ assert_close(edges, expected)def test_noncontiguous(self, device, dtype):batch_size = 3@@ -468,7 +468,7 @@ class TestSobel:op_script = torch.jit.script(op)expected = op(img)actual = op_script(img)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_module(self, device, dtype):img = torch.rand(2, 3, 4, 5, device=device, dtype=dtype)@@ -476,4 +476,4 @@ class TestSobel:op_module = kornia.filters.Sobel()expected = op(img)actual = op_module(img)- assert_allclose(actual, expected)+ assert_close(actual, expected)diff --git a/test/filters/test_unsharp_mask.py b/test/filters/test_unsharp_mask.pyindex ee861348a..ff58a9422 100644--- a/test/filters/test_unsharp_mask.py+++ b/test/filters/test_unsharp_mask.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass Testunsharp:@@ -24,7 +24,7 @@ class Testunsharp:kernel_size = (3, 3)sigma = (1.5, 2.1)actual = kornia.filters.unsharp_mask(input, kernel_size, sigma, "replicate")- assert_allclose(actual, actual)+ assert_close(actual, actual)def test_gradcheck(self, device, dtype):# test parameters@@ -43,7 +43,7 @@ class Testunsharp:params = [(3, 3), (1.5, 1.5)]img = torch.ones(1, 3, 5, 5, device=device, dtype=dtype)- assert_allclose(op(img, *params), op_script(img, *params))+ assert_close(op(img, *params), op_script(img, *params))def test_module(self, device, dtype):params = [(3, 3), (1.5, 1.5)]@@ -51,4 +51,4 @@ class Testunsharp:op_module = kornia.filters.UnsharpMask(*params)img = torch.ones(1, 3, 5, 5, device=device, dtype=dtype)- assert_allclose(op(img, *params), op_module(img))+ assert_close(op(img, *params), op_module(img))diff --git a/test/geometry/calibration/test_undistort.py b/test/geometry/calibration/test_undistort.pyindex a816e92de..25cfad406 100644--- a/test/geometry/calibration/test_undistort.py+++ b/test/geometry/calibration/test_undistort.py@@ -1,9 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allclosefrom kornia.geometry.calibration.undistort import undistort_points+from kornia.testing import assert_closeclass TestUndistortion:@@ -55,7 +55,7 @@ class TestUndistortion:[[1030.5992, 790.65533], [1027.3059, 718.10020], [1024.0700, 645.90600]], device=device, dtype=dtype)ptsu = undistort_points(pts, K, dist)- assert_allclose(ptsu, ptsu_expected, rtol=1e-4, atol=1e-4)+ assert_close(ptsu, ptsu_expected, rtol=1e-4, atol=1e-4)def test_opencv_all_coeff(self, device, dtype):# Test using 14 distortion coefficients@@ -98,7 +98,7 @@ class TestUndistortion:[[1030.8245, 786.3807], [1027.5505, 715.0732], [1024.2753, 644.0319]], device=device, dtype=dtype)ptsu = undistort_points(pts, K, dist)- assert_allclose(ptsu, ptsu_expected, rtol=1e-4, atol=1e-4)+ assert_close(ptsu, ptsu_expected, rtol=1e-4, atol=1e-4)def test_opencv_stereo(self, device, dtype):# Udistort stereo points with data given in two batches using 14 distortion coefficients@@ -182,8 +182,8 @@ class TestUndistortion:)ptsu = undistort_points(pts, K, dist)- assert_allclose(ptsu[0], ptsu_expected1, rtol=1e-4, atol=1e-4)- assert_allclose(ptsu[1], ptsu_expected2, rtol=1e-4, atol=1e-4)+ assert_close(ptsu[0], ptsu_expected1, rtol=1e-4, atol=1e-4)+ assert_close(ptsu[1], ptsu_expected2, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device):points = torch.rand(1, 8, 2, device=device, dtype=torch.float64, requires_grad=True)diff --git a/test/geometry/epipolar/test_essential.py b/test/geometry/epipolar/test_essential.pyindex 9ff8486bf..356e41568 100644--- a/test/geometry/epipolar/test_essential.py+++ b/test/geometry/epipolar/test_essential.py@@ -2,9 +2,9 @@ import pytestimport test_common as utilsimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia.geometry.epipolar as epi+from kornia.testing import assert_closeclass TestEssentialFromFundamental:@@ -31,7 +31,7 @@ class TestEssentialFromFundamental:K2 = torch.rand(1, 3, 3, device=device, dtype=dtype)E_mat = epi.essential_from_fundamental(F_mat, K1, K2)F_hat = epi.fundamental_from_essential(E_mat, K1, K2)- assert_allclose(F_mat, F_hat, atol=1e-4, rtol=1e-4)+ assert_close(F_mat, F_hat, atol=1e-4, rtol=1e-4)def test_shape_large(self, device, dtype):F_mat = torch.rand(1, 2, 3, 3, device=device, dtype=dtype)@@ -54,7 +54,7 @@ class TestEssentialFromFundamental:F_mat_norm = epi.normalize_transformation(F_mat)F_hat_norm = epi.normalize_transformation(F_hat)- assert_allclose(F_mat_norm, F_hat_norm)+ assert_close(F_mat_norm, F_hat_norm)def test_gradcheck(self, device):F_mat = torch.rand(1, 3, 3, device=device, dtype=torch.float64, requires_grad=True)@@ -96,8 +96,8 @@ class TestRelativeCameraMotion:t_expected = -t1R, t = epi.relative_camera_motion(R1, t1, R2, t2)- assert_allclose(R_expected, R)- assert_allclose(t_expected, t)+ assert_close(R_expected, R)+ assert_close(t_expected, t)def test_rotate_z(self, device, dtype):R1 = torch.tensor([[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]], device=device, dtype=dtype)@@ -111,8 +111,8 @@ class TestRelativeCameraMotion:t_expected = t1R, t = epi.relative_camera_motion(R1, t1, R2, t2)- assert_allclose(R_expected, R)- assert_allclose(t_expected, t)+ assert_close(R_expected, R)+ assert_close(t_expected, t)def test_gradcheck(self, device):R1 = torch.rand(1, 3, 3, device=device, dtype=torch.float64, requires_grad=True)@@ -153,7 +153,7 @@ class TestEssentalFromRt:E_from_Rt_norm = epi.normalize_transformation(E_from_Rt)E_from_F_norm = epi.normalize_transformation(E_from_F)# TODO: occasionally failed with error > 0.04- assert_allclose(E_from_Rt_norm, E_from_F_norm, rtol=1e-3, atol=1e-3)+ assert_close(E_from_Rt_norm, E_from_F_norm, rtol=1e-3, atol=1e-3)def test_gradcheck(self, device):R1 = torch.rand(1, 3, 3, device=device, dtype=torch.float64, requires_grad=True)@@ -280,9 +280,9 @@ class TestMotionFromEssentialChooseSolution:mask[:, 1:-1] = TrueRm, tm, Xm = epi.motion_from_essential_choose_solution(E_mat, K1, K2, x1, x2, mask=mask)- assert_allclose(R, Rm)- assert_allclose(t, tm)- assert_allclose(X, Xm[:, 1:-1, :])+ assert_close(R, Rm)+ assert_close(t, tm)+ assert_close(X, Xm[:, 1:-1, :])@pytest.mark.parametrize("num_points", [10, 15, 20])def test_unbatched(self, num_points, device, dtype):@@ -302,9 +302,9 @@ class TestMotionFromEssentialChooseSolution:mask[1:-1] = TrueRm, tm, Xm = epi.motion_from_essential_choose_solution(E_mat, K1, K2, x1, x2, mask=mask)- assert_allclose(R, Rm)- assert_allclose(t, tm)- assert_allclose(X, Xm[1:-1, :])+ assert_close(R, Rm)+ assert_close(t, tm)+ assert_close(X, Xm[1:-1, :])def test_two_view(self, device, dtype):@@ -319,8 +319,8 @@ class TestMotionFromEssentialChooseSolution:E_mat, scene['K1'], scene['K2'], scene['x1'], scene['x2'])- assert_allclose(t, t_hat)- assert_allclose(R, R_hat, rtol=1e-4, atol=1e-4)+ assert_close(t, t_hat)+ assert_close(R, R_hat, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device):E_mat = torch.rand(1, 3, 3, device=device, dtype=torch.float64, requires_grad=True)diff --git a/test/geometry/epipolar/test_fundamental.py b/test/geometry/epipolar/test_fundamental.pyindex 193f4de7b..edcc31f09 100644--- a/test/geometry/epipolar/test_fundamental.py+++ b/test/geometry/epipolar/test_fundamental.py@@ -2,9 +2,9 @@ import pytestimport test_common as utilsimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia.geometry.epipolar as epi+from kornia.testing import assert_closeclass TestNormalizePoints:@@ -29,7 +29,7 @@ class TestNormalizePoints:points_norm, trans = epi.normalize_points(points)points_std, points_mean = torch.std_mean(points_norm, dim=1)- assert_allclose(points_mean, torch.zeros_like(points_mean))+ assert_close(points_mean, torch.zeros_like(points_mean))assert (points_std < 2.0).all()def test_gradcheck(self, device):@@ -56,7 +56,7 @@ class TestNormalizeTransformation:trans_expected = torch.tensor([[[0.0, 0.0, 2.0], [0.0, 4.0, 0.0], [1.0, 0.0, 1.0]]], device=device, dtype=dtype)trans_norm = epi.normalize_transformation(trans)- assert_allclose(trans_norm, trans_expected, atol=1e-4, rtol=1e-4)+ assert_close(trans_norm, trans_expected, atol=1e-4, rtol=1e-4)def test_check_corner_case(self, device, dtype):trans = torch.tensor([[[0.0, 0.0, 1.0], [0.0, 2.0, 0.0], [0.5, 0.0, 0.0]]], device=device, dtype=dtype)@@ -64,7 +64,7 @@ class TestNormalizeTransformation:trans_expected = trans.clone()trans_norm = epi.normalize_transformation(trans)- assert_allclose(trans_norm, trans_expected, atol=1e-4, rtol=1e-4)+ assert_close(trans_norm, trans_expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device):trans = torch.rand(2, 3, 3, device=device, requires_grad=True, dtype=torch.float64)@@ -148,7 +148,7 @@ class TestFindFundamental:)F_mat = epi.find_fundamental(points1, points2, weights)- assert_allclose(F_mat, Fm_expected, rtol=1e-4, atol=1e-4)+ assert_close(F_mat, Fm_expected, rtol=1e-4, atol=1e-4)@pytest.mark.xfail(reason="TODO: fix #685")def test_synthetic_sampson(self, device, dtype):@@ -162,7 +162,7 @@ class TestFindFundamental:F_est = epi.find_fundamental(x1, x2, weights)error = epi.sampson_epipolar_distance(x1, x2, F_est)- assert_allclose(error, torch.tensor(0.0, device=device, dtype=dtype), atol=1e-4, rtol=1e-4)+ assert_close(error, torch.tensor(0.0, device=device, dtype=dtype), atol=1e-4, rtol=1e-4)def test_gradcheck(self, device):points1 = torch.rand(1, 10, 2, device=device, dtype=torch.float64, requires_grad=True)@@ -207,7 +207,7 @@ class TestComputeCorrespondEpilimes:)lines_est = epi.compute_correspond_epilines(point, F_mat)- assert_allclose(lines_est, lines_expected, rtol=1e-4, atol=1e-4)+ assert_close(lines_est, lines_expected, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device):point = torch.rand(1, 4, 2, device=device, dtype=torch.float64, requires_grad=True)@@ -248,7 +248,7 @@ class TestFundamentlFromEssential:F_mat_norm = epi.normalize_transformation(F_mat)F_hat_norm = epi.normalize_transformation(F_hat)- assert_allclose(F_mat_norm, F_hat_norm, atol=1e-4, rtol=1e-4)+ assert_close(F_mat_norm, F_hat_norm, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device):E_mat = torch.rand(1, 3, 3, device=device, dtype=torch.float64, requires_grad=True)@@ -293,7 +293,7 @@ class TestFundamentalFromProjections:F_mat_norm = epi.normalize_transformation(F_mat)F_hat_norm = epi.normalize_transformation(F_hat)- assert_allclose(F_mat_norm, F_hat_norm, atol=1e-4, rtol=1e-4)+ assert_close(F_mat_norm, F_hat_norm, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device):P1 = torch.rand(1, 3, 4, device=device, dtype=torch.float64, requires_grad=True)diff --git a/test/geometry/epipolar/test_numeric.py b/test/geometry/epipolar/test_numeric.pyindex 645508d92..678849f93 100644--- a/test/geometry/epipolar/test_numeric.py+++ b/test/geometry/epipolar/test_numeric.py@@ -1,9 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia.geometry.epipolar as epi+from kornia.testing import assert_closeclass TestSkewSymmetric:@@ -22,9 +22,9 @@ class TestSkewSymmetric:def test_mean_std(self, device, dtype):vec = torch.tensor([[1.0, 2.0, 3.0]], device=device, dtype=dtype)cross_product_matrix = epi.cross_product_matrix(vec)- assert_allclose(cross_product_matrix[..., 0, 1], -cross_product_matrix[..., 1, 0])- assert_allclose(cross_product_matrix[..., 0, 2], -cross_product_matrix[..., 2, 0])- assert_allclose(cross_product_matrix[..., 1, 2], -cross_product_matrix[..., 2, 1])+ assert_close(cross_product_matrix[..., 0, 1], -cross_product_matrix[..., 1, 0])+ assert_close(cross_product_matrix[..., 0, 2], -cross_product_matrix[..., 2, 0])+ assert_close(cross_product_matrix[..., 1, 2], -cross_product_matrix[..., 2, 1])def test_gradcheck(self, device):vec = torch.ones(2, 3, device=device, requires_grad=True, dtype=torch.float64)diff --git a/test/geometry/epipolar/test_projection.py b/test/geometry/epipolar/test_projection.pyindex f62779480..4513ad025 100644--- a/test/geometry/epipolar/test_projection.py+++ b/test/geometry/epipolar/test_projection.py@@ -1,9 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia.geometry.epipolar as epi+from kornia.testing import assert_closeclass TestIntrinsicsLike:@@ -56,7 +56,7 @@ class TestScaleIntrinsics:)camera_matrix_scale = epi.scale_intrinsics(camera_matrix, scale_factor)- assert_allclose(camera_matrix_scale, camera_matrix_expected, atol=1e-4, rtol=1e-4)+ assert_close(camera_matrix_scale, camera_matrix_expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device):scale_factor = torch.ones(1, device=device, dtype=torch.float64, requires_grad=True)@@ -93,7 +93,7 @@ class TestProjectionFromKRt:)P_estimated = epi.projection_from_KRt(K, R, t)- assert_allclose(P_estimated, P_expected, atol=1e-4, rtol=1e-4)+ assert_close(P_estimated, P_expected, atol=1e-4, rtol=1e-4)def test_krt_from_projection(self, device, dtype):P = torch.tensor(@@ -107,9 +107,9 @@ class TestProjectionFromKRt:t_expected = torch.tensor([[[1.0], [2.0], [3.0]]], device=device, dtype=dtype)K_estimated, R_estimated, t_estimated = epi.KRt_from_projection(P)- assert_allclose(K_estimated, K_expected, atol=1e-4, rtol=1e-4)- assert_allclose(R_estimated, R_expected, atol=1e-4, rtol=1e-4)- assert_allclose(t_estimated, t_expected, atol=1e-4, rtol=1e-4)+ assert_close(K_estimated, K_expected, atol=1e-4, rtol=1e-4)+ assert_close(R_estimated, R_expected, atol=1e-4, rtol=1e-4)+ assert_close(t_estimated, t_expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device):K = torch.rand(1, 3, 3, device=device, dtype=torch.float64, requires_grad=True)@@ -176,9 +176,9 @@ class TestKRtFromProjection:t_expected = torch.tensor([[[-6.477699], [1.129624], [0.143123]]], device=device, dtype=dtype)K_estimated, R_estimated, t_estimated = epi.KRt_from_projection(P)- assert_allclose(K_estimated, K_expected, atol=1e-4, rtol=1e-4)- assert_allclose(R_estimated, R_expected, atol=1e-4, rtol=1e-4)- assert_allclose(t_estimated, t_expected, atol=1e-4, rtol=1e-4)+ assert_close(K_estimated, K_expected, atol=1e-4, rtol=1e-4)+ assert_close(R_estimated, R_expected, atol=1e-4, rtol=1e-4)+ assert_close(t_estimated, t_expected, atol=1e-4, rtol=1e-4)def test_projection_from_krt(self, device, dtype):K = torch.tensor(@@ -202,7 +202,7 @@ class TestKRtFromProjection:)P_estimated = epi.projection_from_KRt(K, R, t)- assert_allclose(P_estimated, P_expected, atol=1e-4, rtol=1e-4)+ assert_close(P_estimated, P_expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device):P_mat = torch.rand(1, 3, 4, device=device, dtype=torch.float64, requires_grad=True)diff --git a/test/geometry/epipolar/test_triangulation.py b/test/geometry/epipolar/test_triangulation.pyindex c9d31bce4..e53789002 100644--- a/test/geometry/epipolar/test_triangulation.py+++ b/test/geometry/epipolar/test_triangulation.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.geometry.epipolar as epi+from kornia.testing import assert_closeclass TestTriangulation:@@ -40,8 +40,8 @@ class TestTriangulation:X = epi.triangulate_points(P1, P2, x1, x2)x_reprojected = kornia.transform_points(scene['P'], X.expand(num_views, -1, -1))- assert_allclose(scene['points3d'], X, rtol=1e-4, atol=1e-4)- assert_allclose(scene['points2d'], x_reprojected, rtol=1e-4, atol=1e-4)+ assert_close(scene['points3d'], X, rtol=1e-4, atol=1e-4)+ assert_close(scene['points2d'], x_reprojected, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device):points1 = torch.rand(1, 8, 2, device=device, dtype=torch.float64, requires_grad=True)diff --git a/test/geometry/subpix/test_dsnt.py b/test/geometry/subpix/test_dsnt.pyindex 0c8fa46c6..347054170 100644--- a/test/geometry/subpix/test_dsnt.py+++ b/test/geometry/subpix/test_dsnt.py@@ -1,8 +1,8 @@import pytestimport torch-from torch.testing import assert_allcloseimport kornia+from kornia.testing import assert_closeclass TestRenderGaussian2d:@@ -24,13 +24,13 @@ class TestRenderGaussian2d:mean = torch.tensor([2.0, 2.0], dtype=dtype, device=device)std = torch.tensor([1.0, 1.0], dtype=dtype, device=device)actual = kornia.geometry.dsnt.render_gaussian2d(mean, std, (5, 5), False)- assert_allclose(actual, gaussian, rtol=0, atol=1e-4)+ assert_close(actual, gaussian, rtol=0, atol=1e-4)def test_normalized_coordinates(self, gaussian, device, dtype):mean = torch.tensor([0.0, 0.0], dtype=dtype, device=device)std = torch.tensor([0.25, 0.25], dtype=dtype, device=device)actual = kornia.geometry.dsnt.render_gaussian2d(mean, std, (5, 5), True)- assert_allclose(actual, gaussian, rtol=0, atol=1e-4)+ assert_close(actual, gaussian, rtol=0, atol=1e-4)def test_jit(self, device, dtype):mean = torch.tensor([0.0, 0.0], dtype=dtype, device=device)@@ -38,7 +38,7 @@ class TestRenderGaussian2d:args = (mean, std, (5, 5), True)op = kornia.geometry.dsnt.render_gaussian2dop_jit = kornia.jit.render_gaussian2d- assert_allclose(op(*args), op_jit(*args), rtol=0, atol=1e-5)+ assert_close(op(*args), op_jit(*args), rtol=0, atol=1e-5)def test_jit_trace(self, device, dtype):def op(mean, std):@@ -48,7 +48,7 @@ class TestRenderGaussian2d:std = torch.tensor([0.25, 0.25], dtype=dtype, device=device)args = (mean, std)op_jit = torch.jit.trace(op, args)- assert_allclose(op(*args), op_jit(*args), rtol=0, atol=1e-5)+ assert_close(op(*args), op_jit(*args), rtol=0, atol=1e-5)class TestSpatialSoftmax2d:@@ -60,17 +60,17 @@ class TestSpatialSoftmax2d:actual = kornia.geometry.dsnt.spatial_softmax2d(input)assert actual.lt(0).sum().item() == 0, 'expected no negative values'sums = actual.sum(-1).sum(-1)- assert_allclose(sums, torch.ones_like(sums))+ assert_close(sums, torch.ones_like(sums))def test_jit(self, input):op = kornia.geometry.dsnt.spatial_softmax2dop_jit = kornia.jit.spatial_softmax2d- assert_allclose(op(input), op_jit(input), rtol=0, atol=1e-5)+ assert_close(op(input), op_jit(input), rtol=0, atol=1e-5)def test_jit_trace(self, input):op = kornia.geometry.dsnt.spatial_softmax2dop_jit = torch.jit.trace(op, (input,))- assert_allclose(op(input), op_jit(input), rtol=0, atol=1e-5)+ assert_close(op(input), op_jit(input), rtol=0, atol=1e-5)class TestSpatialExpectation2d:@@ -90,18 +90,18 @@ class TestSpatialExpectation2d:def test_forward(self, example):input, expected_norm, expected_px = exampleactual_norm = kornia.geometry.dsnt.spatial_expectation2d(input, True)- assert_allclose(actual_norm, expected_norm)+ assert_close(actual_norm, expected_norm)actual_px = kornia.geometry.dsnt.spatial_expectation2d(input, False)- assert_allclose(actual_px, expected_px)+ assert_close(actual_px, expected_px)def test_jit(self, example):input = example[0]op = kornia.geometry.dsnt.spatial_expectation2dop_jit = kornia.jit.spatial_expectation2d- assert_allclose(op(input), op_jit(input), rtol=0, atol=1e-5)+ assert_close(op(input), op_jit(input), rtol=0, atol=1e-5)def test_jit_trace(self, example):input = example[0]op = kornia.geometry.dsnt.spatial_expectation2dop_jit = torch.jit.trace(op, (input,))- assert_allclose(op(input), op_jit(input), rtol=0, atol=1e-5)+ assert_close(op(input), op_jit(input), rtol=0, atol=1e-5)diff --git a/test/geometry/subpix/test_spatial_softargmax.py b/test/geometry/subpix/test_spatial_softargmax.pyindex c57cfd09f..e4cabcb2a 100644--- a/test/geometry/subpix/test_spatial_softargmax.py+++ b/test/geometry/subpix/test_spatial_softargmax.py@@ -2,11 +2,11 @@ import pytestimport torchfrom torch.autograd import gradcheckfrom torch.nn.functional import mse_loss-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utilsfrom kornia.geometry.subpix.spatial_soft_argmax import _get_center_kernel2d, _get_center_kernel3d+from kornia.testing import assert_closeclass TestCenterKernel2d:@@ -30,14 +30,14 @@ class TestCenterKernel2d:device=device,dtype=dtype,)- assert_allclose(kernel, expected, atol=1e-4, rtol=1e-4)+ assert_close(kernel, expected, atol=1e-4, rtol=1e-4)def test_even(self, device, dtype):kernel = _get_center_kernel2d(2, 2, device=device).to(dtype=dtype)expected = torch.ones(2, 2, 2, 2, device=device, dtype=dtype) * 0.25expected[0, 1] = 0expected[1, 0] = 0- assert_allclose(kernel, expected, atol=1e-4, rtol=1e-4)+ assert_close(kernel, expected, atol=1e-4, rtol=1e-4)class TestCenterKernel3d:@@ -51,7 +51,7 @@ class TestCenterKernel3d:expected[0, 0, 1, 2, 3] = 1.0expected[1, 1, 1, 2, 3] = 1.0expected[2, 2, 1, 2, 3] = 1.0- assert_allclose(kernel, expected, atol=1e-4, rtol=1e-4)+ assert_close(kernel, expected, atol=1e-4, rtol=1e-4)def test_even(self, device, dtype):kernel = _get_center_kernel3d(2, 4, 3, device=device).to(dtype=dtype)@@ -59,7 +59,7 @@ class TestCenterKernel3d:expected[0, 0, :, 1:3, 1] = 0.25expected[1, 1, :, 1:3, 1] = 0.25expected[2, 2, :, 1:3, 1] = 0.25- assert_allclose(kernel, expected, atol=1e-4, rtol=1e-4)+ assert_close(kernel, expected, atol=1e-4, rtol=1e-4)class TestSpatialSoftArgmax2d:@@ -78,32 +78,32 @@ class TestSpatialSoftArgmax2d:input[..., 0, 0] = 1e16coord = kornia.spatial_soft_argmax2d(input, normalized_coordinates=True)- assert_allclose(coord[..., 0].item(), -1.0, atol=1e-4, rtol=1e-4)- assert_allclose(coord[..., 1].item(), -1.0, atol=1e-4, rtol=1e-4)+ assert_close(coord[..., 0].item(), -1.0, atol=1e-4, rtol=1e-4)+ assert_close(coord[..., 1].item(), -1.0, atol=1e-4, rtol=1e-4)def test_top_left(self, device, dtype):input = torch.zeros(1, 1, 2, 3, device=device, dtype=dtype)input[..., 0, 0] = 1e16coord = kornia.spatial_soft_argmax2d(input, normalized_coordinates=False)- assert_allclose(coord[..., 0].item(), 0.0, atol=1e-4, rtol=1e-4)- assert_allclose(coord[..., 1].item(), 0.0, atol=1e-4, rtol=1e-4)+ assert_close(coord[..., 0].item(), 0.0, atol=1e-4, rtol=1e-4)+ assert_close(coord[..., 1].item(), 0.0, atol=1e-4, rtol=1e-4)def test_bottom_right_normalized(self, device, dtype):input = torch.zeros(1, 1, 2, 3, device=device, dtype=dtype)input[..., -1, -1] = 1e16coord = kornia.spatial_soft_argmax2d(input, normalized_coordinates=True)- assert_allclose(coord[..., 0].item(), 1.0, atol=1e-4, rtol=1e-4)- assert_allclose(coord[..., 1].item(), 1.0, atol=1e-4, rtol=1e-4)+ assert_close(coord[..., 0].item(), 1.0, atol=1e-4, rtol=1e-4)+ assert_close(coord[..., 1].item(), 1.0, atol=1e-4, rtol=1e-4)def test_bottom_right(self, device, dtype):input = torch.zeros(1, 1, 2, 3, device=device, dtype=dtype)input[..., -1, -1] = 1e16coord = kornia.spatial_soft_argmax2d(input, normalized_coordinates=False)- assert_allclose(coord[..., 0].item(), 2.0, atol=1e-4, rtol=1e-4)- assert_allclose(coord[..., 1].item(), 1.0, atol=1e-4, rtol=1e-4)+ assert_close(coord[..., 0].item(), 2.0, atol=1e-4, rtol=1e-4)+ assert_close(coord[..., 1].item(), 1.0, atol=1e-4, rtol=1e-4)def test_batch2_n2(self, device, dtype):input = torch.zeros(2, 2, 2, 3, device=device, dtype=dtype)@@ -113,14 +113,14 @@ class TestSpatialSoftArgmax2d:input[1, 1, -1, -1] = 1e16 # bottom-rightcoord = kornia.spatial_soft_argmax2d(input)- assert_allclose(coord[0, 0, 0].item(), -1.0, atol=1e-4, rtol=1e-4) # top-left- assert_allclose(coord[0, 0, 1].item(), -1.0, atol=1e-4, rtol=1e-4)- assert_allclose(coord[0, 1, 0].item(), 1.0, atol=1e-4, rtol=1e-4) # top-right- assert_allclose(coord[0, 1, 1].item(), -1.0, atol=1e-4, rtol=1e-4)- assert_allclose(coord[1, 0, 0].item(), -1.0, atol=1e-4, rtol=1e-4) # bottom-left- assert_allclose(coord[1, 0, 1].item(), 1.0, atol=1e-4, rtol=1e-4)- assert_allclose(coord[1, 1, 0].item(), 1.0, atol=1e-4, rtol=1e-4) # bottom-right- assert_allclose(coord[1, 1, 1].item(), 1.0, atol=1e-4, rtol=1e-4)+ assert_close(coord[0, 0, 0].item(), -1.0, atol=1e-4, rtol=1e-4) # top-left+ assert_close(coord[0, 0, 1].item(), -1.0, atol=1e-4, rtol=1e-4)+ assert_close(coord[0, 1, 0].item(), 1.0, atol=1e-4, rtol=1e-4) # top-right+ assert_close(coord[0, 1, 1].item(), -1.0, atol=1e-4, rtol=1e-4)+ assert_close(coord[1, 0, 0].item(), -1.0, atol=1e-4, rtol=1e-4) # bottom-left+ assert_close(coord[1, 0, 1].item(), 1.0, atol=1e-4, rtol=1e-4)+ assert_close(coord[1, 1, 0].item(), 1.0, atol=1e-4, rtol=1e-4) # bottom-right+ assert_close(coord[1, 1, 1].item(), 1.0, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):input = torch.rand(2, 3, 3, 2, device=device, dtype=dtype)@@ -133,24 +133,22 @@ class TestSpatialSoftArgmax2d:std = torch.tensor([1.0, 1.0], device=device, dtype=dtype)hm = kornia.geometry.dsnt.spatial_softmax2d(input)- assert_allclose(- hm.sum(-1).sum(-1), torch.tensor([[1.0, 1.0]], device=device, dtype=dtype), atol=1e-4, rtol=1e-4- )+ assert_close(hm.sum(-1).sum(-1), torch.tensor([[1.0, 1.0]], device=device, dtype=dtype), atol=1e-4, rtol=1e-4)pred = kornia.geometry.dsnt.spatial_expectation2d(hm)- assert_allclose(+ assert_close(pred, torch.as_tensor([[[0.0, 0.0], [0.0, 0.0]]], device=device, dtype=dtype), atol=1e-4, rtol=1e-4)loss1 = mse_loss(pred, target, size_average=None, reduce=None, reduction='none').mean(-1, keepdim=False)expected_loss1 = torch.as_tensor([[0.0, 1.0]], device=device, dtype=dtype)- assert_allclose(loss1, expected_loss1, atol=1e-4, rtol=1e-4)+ assert_close(loss1, expected_loss1, atol=1e-4, rtol=1e-4)target_hm = kornia.geometry.dsnt.render_gaussian2d(target, std, input.shape[-2:]).contiguous()loss2 = kornia.losses.js_div_loss_2d(hm, target_hm, reduction='none')expected_loss2 = torch.as_tensor([[0.0087, 0.0818]], device=device, dtype=dtype)- assert_allclose(loss2, expected_loss2, rtol=0, atol=1e-3)+ assert_close(loss2, expected_loss2, rtol=0, atol=1e-3)loss = (loss1 + loss2).mean()loss.backward()@@ -159,13 +157,13 @@ class TestSpatialSoftArgmax2d:input = torch.rand((2, 3, 7, 7), dtype=dtype, device=device)op = kornia.spatial_soft_argmax2dop_jit = kornia.jit.spatial_soft_argmax2d- assert_allclose(op(input), op_jit(input), rtol=0, atol=1e-5)+ assert_close(op(input), op_jit(input), rtol=0, atol=1e-5)def test_jit_trace(self, device, dtype):input = torch.rand((2, 3, 7, 7), dtype=dtype, device=device)op = kornia.spatial_soft_argmax2dop_jit = torch.jit.trace(op, (input,))- assert_allclose(op(input), op_jit(input), rtol=0, atol=1e-5)+ assert_close(op(input), op_jit(input), rtol=0, atol=1e-5)class TestConvSoftArgmax2d:@@ -222,8 +220,8 @@ class TestConvSoftArgmax2d:[[[[[1.0, 3.0], [1.0, 3.0]], [[1.0, 1.0], [3.0, 3.0]]]]], device=device, dtype=dtype)coords, val = softargmax(input)- assert_allclose(val, expected_val, atol=1e-4, rtol=1e-4)- assert_allclose(coords, expected_coord, atol=1e-4, rtol=1e-4)+ assert_close(val, expected_val, atol=1e-4, rtol=1e-4)+ assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)def test_hot_diag(self, device, dtype):input = torch.tensor(@@ -249,8 +247,8 @@ class TestConvSoftArgmax2d:[[[[[1.0, 3.0], [1.0, 3.0]], [[1.0, 1.0], [3.0, 3.0]]]]], device=device, dtype=dtype)coords, val = softargmax(input)- assert_allclose(val, expected_val, atol=1e-4, rtol=1e-4)- assert_allclose(coords, expected_coord, atol=1e-4, rtol=1e-4)+ assert_close(val, expected_val, atol=1e-4, rtol=1e-4)+ assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)def test_cold_diag_norm(self, device, dtype):input = torch.tensor(@@ -276,8 +274,8 @@ class TestConvSoftArgmax2d:[[[[[-0.5, 0.5], [-0.5, 0.5]], [[-0.5, -0.5], [0.5, 0.5]]]]], device=device, dtype=dtype)coords, val = softargmax(input)- assert_allclose(val, expected_val, atol=1e-4, rtol=1e-4)- assert_allclose(coords, expected_coord, atol=1e-4, rtol=1e-4)+ assert_close(val, expected_val, atol=1e-4, rtol=1e-4)+ assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)def test_hot_diag_norm(self, device, dtype):input = torch.tensor(@@ -303,8 +301,8 @@ class TestConvSoftArgmax2d:[[[[[-0.5, 0.5], [-0.5, 0.5]], [[-0.5, -0.5], [0.5, 0.5]]]]], device=device, dtype=dtype)coords, val = softargmax(input)- assert_allclose(val, expected_val, atol=1e-4, rtol=1e-4)- assert_allclose(coords, expected_coord, atol=1e-4, rtol=1e-4)+ assert_close(val, expected_val, atol=1e-4, rtol=1e-4)+ assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)class TestConvSoftArgmax3d:@@ -353,8 +351,8 @@ class TestConvSoftArgmax3d:dtype=dtype,)coords, val = softargmax(input)- assert_allclose(val, expected_val, atol=1e-4, rtol=1e-4)- assert_allclose(coords, expected_coord, atol=1e-4, rtol=1e-4)+ assert_close(val, expected_val, atol=1e-4, rtol=1e-4)+ assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)def test_hot_diag(self, device, dtype):input = torch.tensor(@@ -384,8 +382,8 @@ class TestConvSoftArgmax3d:dtype=dtype,)coords, val = softargmax(input)- assert_allclose(val, expected_val, atol=1e-4, rtol=1e-4)- assert_allclose(coords, expected_coord, atol=1e-4, rtol=1e-4)+ assert_close(val, expected_val, atol=1e-4, rtol=1e-4)+ assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)def test_cold_diag_norm(self, device, dtype):input = torch.tensor(@@ -415,8 +413,8 @@ class TestConvSoftArgmax3d:dtype=dtype,)coords, val = softargmax(input)- assert_allclose(val, expected_val, atol=1e-4, rtol=1e-4)- assert_allclose(coords, expected_coord, atol=1e-4, rtol=1e-4)+ assert_close(val, expected_val, atol=1e-4, rtol=1e-4)+ assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)def test_hot_diag_norm(self, device, dtype):input = torch.tensor(@@ -446,8 +444,8 @@ class TestConvSoftArgmax3d:dtype=dtype,)coords, val = softargmax(input)- assert_allclose(val, expected_val, atol=1e-4, rtol=1e-4)- assert_allclose(coords, expected_coord, atol=1e-4, rtol=1e-4)+ assert_close(val, expected_val, atol=1e-4, rtol=1e-4)+ assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)class TestConvQuadInterp3d:@@ -611,5 +609,5 @@ class TestConvQuadInterp3d:dtype=dtype,)coords, val = softargmax(input)- assert_allclose(val, expected_val, atol=1e-4, rtol=1e-4)- assert_allclose(coords, expected_coord, atol=1e-4, rtol=1e-4)+ assert_close(val, expected_val, atol=1e-4, rtol=1e-4)+ assert_close(coords, expected_coord, atol=1e-4, rtol=1e-4)diff --git a/test/geometry/test_conversions.py b/test/geometry/test_conversions.pyindex e7bada7a3..a00751fb4 100644--- a/test/geometry/test_conversions.py+++ b/test/geometry/test_conversions.py@@ -4,11 +4,10 @@ import numpy as npimport pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniafrom kornia.geometry.conversions import QuaternionCoeffOrder-from kornia.testing import create_eye_batch, tensor_to_gradcheck_var+from kornia.testing import assert_close, create_eye_batch, tensor_to_gradcheck_var@pytest.fixture@@ -61,13 +60,13 @@ class TestAngleAxisToQuaternion:expected = torch.tensor((0.0, 0.0, 0.0, 1.0), device=device, dtype=dtype)with pytest.warns(UserWarning):quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_zero_angle(self, device, dtype, atol, rtol):angle_axis = torch.tensor((0.0, 0.0, 0.0), device=device, dtype=dtype)expected = torch.tensor((1.0, 0.0, 0.0, 0.0), device=device, dtype=dtype)quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_small_angle_x_xyzw(self, device, dtype, atol, rtol):theta = 1.0e-2@@ -75,14 +74,14 @@ class TestAngleAxisToQuaternion:expected = torch.tensor((np.sin(theta / 2.0), 0.0, 0.0, np.cos(theta / 2.0)), device=device, dtype=dtype)with pytest.warns(UserWarning):quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_small_angle_x(self, device, dtype, atol, rtol):theta = 1.0e-2angle_axis = torch.tensor((theta, 0.0, 0.0), device=device, dtype=dtype)expected = torch.tensor((np.cos(theta / 2.0), np.sin(theta / 2.0), 0.0, 0.0), device=device, dtype=dtype)quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_small_angle_y_xyzw(self, device, dtype, atol, rtol):theta = 1.0e-2@@ -90,14 +89,14 @@ class TestAngleAxisToQuaternion:expected = torch.tensor((0.0, np.sin(theta / 2.0), 0.0, np.cos(theta / 2.0)), device=device, dtype=dtype)with pytest.warns(UserWarning):quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_small_angle_y(self, device, dtype, atol, rtol):theta = 1.0e-2angle_axis = torch.tensor((0.0, theta, 0.0), device=device, dtype=dtype)expected = torch.tensor((np.cos(theta / 2.0), 0.0, np.sin(theta / 2.0), 0.0), device=device, dtype=dtype)quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_small_angle_z_xyzw(self, device, dtype, atol, rtol):theta = 1.0e-2@@ -105,14 +104,14 @@ class TestAngleAxisToQuaternion:expected = torch.tensor((0.0, 0.0, np.sin(theta / 2.0), np.cos(theta / 2.0)), device=device, dtype=dtype)with pytest.warns(UserWarning):quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_small_angle_z(self, device, dtype, atol, rtol):theta = 1.0e-2angle_axis = torch.tensor((0.0, 0.0, theta), device=device, dtype=dtype)expected = torch.tensor((np.cos(theta / 2.0), 0.0, 0.0, np.sin(theta / 2.0)), device=device, dtype=dtype)quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_x_rotation_xyzw(self, device, dtype, atol, rtol):half_sqrt2 = 0.5 * np.sqrt(2.0)@@ -120,14 +119,14 @@ class TestAngleAxisToQuaternion:expected = torch.tensor((half_sqrt2, 0.0, 0.0, half_sqrt2), device=device, dtype=dtype)with pytest.warns(UserWarning):quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_x_rotation(self, device, dtype, atol, rtol):half_sqrt2 = 0.5 * np.sqrt(2.0)angle_axis = torch.tensor((kornia.pi / 2.0, 0.0, 0.0), device=device, dtype=dtype)expected = torch.tensor((half_sqrt2, half_sqrt2, 0.0, 0.0), device=device, dtype=dtype)quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_y_rotation_xyzw(self, device, dtype, atol, rtol):half_sqrt2 = 0.5 * np.sqrt(2.0)@@ -135,14 +134,14 @@ class TestAngleAxisToQuaternion:expected = torch.tensor((0.0, half_sqrt2, 0.0, half_sqrt2), device=device, dtype=dtype)with pytest.warns(UserWarning):quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_y_rotation(self, device, dtype, atol, rtol):half_sqrt2 = 0.5 * np.sqrt(2.0)angle_axis = torch.tensor((0.0, kornia.pi / 2.0, 0.0), device=device, dtype=dtype)expected = torch.tensor((half_sqrt2, 0.0, half_sqrt2, 0.0), device=device, dtype=dtype)quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_z_rotation_xyzw(self, device, dtype, atol, rtol):half_sqrt2 = 0.5 * np.sqrt(2.0)@@ -150,14 +149,14 @@ class TestAngleAxisToQuaternion:expected = torch.tensor((0.0, 0.0, half_sqrt2, half_sqrt2), device=device, dtype=dtype)with pytest.warns(UserWarning):quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_z_rotation(self, device, dtype, atol, rtol):half_sqrt2 = 0.5 * np.sqrt(2.0)angle_axis = torch.tensor((0.0, 0.0, kornia.pi / 2.0), device=device, dtype=dtype)expected = torch.tensor((half_sqrt2, 0.0, 0.0, half_sqrt2), device=device, dtype=dtype)quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_gradcheck_xyzw(self, device, dtype):eps = torch.finfo(dtype).eps@@ -213,52 +212,52 @@ class TestQuaternionToAngleAxis:expected = torch.tensor((0.0, 0.0, 0.0), device=device, dtype=dtype)with pytest.warns(UserWarning):angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.XYZW)- assert_allclose(angle_axis, expected, atol=atol, rtol=rtol)+ assert_close(angle_axis, expected, atol=atol, rtol=rtol)def test_unit_quaternion(self, device, dtype, atol, rtol):quaternion = torch.tensor((1.0, 0.0, 0.0, 0.0), device=device, dtype=dtype)expected = torch.tensor((0.0, 0.0, 0.0), device=device, dtype=dtype)angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(angle_axis, expected, atol=atol, rtol=rtol)+ assert_close(angle_axis, expected, atol=atol, rtol=rtol)def test_x_rotation_xyzw(self, device, dtype, atol, rtol):quaternion = torch.tensor((1.0, 0.0, 0.0, 0.0), device=device, dtype=dtype)expected = torch.tensor((kornia.pi, 0.0, 0.0), device=device, dtype=dtype)with pytest.warns(UserWarning):angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.XYZW)- assert_allclose(angle_axis, expected, atol=atol, rtol=rtol)+ assert_close(angle_axis, expected, atol=atol, rtol=rtol)def test_x_rotation(self, device, dtype, atol, rtol):quaternion = torch.tensor((0.0, 1.0, 0.0, 0.0), device=device, dtype=dtype)expected = torch.tensor((kornia.pi, 0.0, 0.0), device=device, dtype=dtype)angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(angle_axis, expected, atol=atol, rtol=rtol)+ assert_close(angle_axis, expected, atol=atol, rtol=rtol)def test_y_rotation_xyzw(self, device, dtype, atol, rtol):quaternion = torch.tensor((0.0, 1.0, 0.0, 0.0), device=device, dtype=dtype)expected = torch.tensor((0.0, kornia.pi, 0.0), device=device, dtype=dtype)with pytest.warns(UserWarning):angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.XYZW)- assert_allclose(angle_axis, expected, atol=atol, rtol=rtol)+ assert_close(angle_axis, expected, atol=atol, rtol=rtol)def test_y_rotation(self, device, dtype, atol, rtol):quaternion = torch.tensor((0.0, 0.0, 1.0, 0.0), device=device, dtype=dtype)expected = torch.tensor((0.0, kornia.pi, 0.0), device=device, dtype=dtype)angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(angle_axis, expected, atol=atol, rtol=rtol)+ assert_close(angle_axis, expected, atol=atol, rtol=rtol)def test_z_rotation_xyzw(self, device, dtype, atol, rtol):quaternion = torch.tensor((0.0, 0.0, 0.5, np.sqrt(3.0) / 2.0), device=device, dtype=dtype)expected = torch.tensor((0.0, 0.0, kornia.pi / 3.0), device=device, dtype=dtype)with pytest.warns(UserWarning):angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.XYZW)- assert_allclose(angle_axis, expected, atol=atol, rtol=rtol)+ assert_close(angle_axis, expected, atol=atol, rtol=rtol)def test_z_rotation(self, device, dtype, atol, rtol):quaternion = torch.tensor((np.sqrt(3.0) / 2.0, 0.0, 0.0, 0.5), device=device, dtype=dtype)expected = torch.tensor((0.0, 0.0, kornia.pi / 3.0), device=device, dtype=dtype)angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(angle_axis, expected, atol=atol, rtol=rtol)+ assert_close(angle_axis, expected, atol=atol, rtol=rtol)def test_small_angle_x_xyzw(self, device, dtype, atol, rtol):theta = 1.0e-2@@ -266,14 +265,14 @@ class TestQuaternionToAngleAxis:expected = torch.tensor((theta, 0.0, 0.0), device=device, dtype=dtype)with pytest.warns(UserWarning):angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.XYZW)- assert_allclose(angle_axis, expected, atol=atol, rtol=rtol)+ assert_close(angle_axis, expected, atol=atol, rtol=rtol)def test_small_angle_x(self, device, dtype, atol, rtol):theta = 1.0e-2quaternion = torch.tensor((np.cos(theta / 2.0), np.sin(theta / 2.0), 0.0, 0.0), device=device, dtype=dtype)expected = torch.tensor((theta, 0.0, 0.0), device=device, dtype=dtype)angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(angle_axis, expected, atol=atol, rtol=rtol)+ assert_close(angle_axis, expected, atol=atol, rtol=rtol)def test_small_angle_y_xyzw(self, device, dtype, atol, rtol):theta = 1.0e-2@@ -281,14 +280,14 @@ class TestQuaternionToAngleAxis:expected = torch.tensor((0.0, theta, 0.0), device=device, dtype=dtype)with pytest.warns(UserWarning):angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.XYZW)- assert_allclose(angle_axis, expected, atol=atol, rtol=rtol)+ assert_close(angle_axis, expected, atol=atol, rtol=rtol)def test_small_angle_y(self, device, dtype, atol, rtol):theta = 1.0e-2quaternion = torch.tensor((np.cos(theta / 2), 0.0, np.sin(theta / 2), 0.0), device=device, dtype=dtype)expected = torch.tensor((0.0, theta, 0.0), device=device, dtype=dtype)angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(angle_axis, expected, atol=atol, rtol=rtol)+ assert_close(angle_axis, expected, atol=atol, rtol=rtol)def test_small_angle_z_xyzw(self, device, dtype, atol, rtol):theta = 1.0e-2@@ -296,14 +295,14 @@ class TestQuaternionToAngleAxis:expected = torch.tensor((0.0, 0.0, theta), device=device, dtype=dtype)with pytest.warns(UserWarning):angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.XYZW)- assert_allclose(angle_axis, expected, atol=atol, rtol=rtol)+ assert_close(angle_axis, expected, atol=atol, rtol=rtol)def test_small_angle_z(self, device, dtype, atol, rtol):theta = 1.0e-2quaternion = torch.tensor((np.cos(theta / 2), 0.0, 0.0, np.sin(theta / 2)), device=device, dtype=dtype)expected = torch.tensor((0.0, 0.0, theta), device=device, dtype=dtype)angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(angle_axis, expected, atol=atol, rtol=rtol)+ assert_close(angle_axis, expected, atol=atol, rtol=rtol)def test_gradcheck_xyzw(self, device, dtype):eps = torch.finfo(dtype).eps@@ -348,13 +347,13 @@ class TestRotationMatrixToQuaternion:expected = torch.tensor((0.0, 0.0, 0.0, 1.0), device=device, dtype=dtype)with pytest.warns(UserWarning):quaternion = kornia.rotation_matrix_to_quaternion(matrix, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_identity(self, device, dtype, atol, rtol):matrix = torch.tensor(((1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)), device=device, dtype=dtype)expected = torch.tensor((1.0, 0.0, 0.0, 0.0), device=device, dtype=dtype)quaternion = kornia.rotation_matrix_to_quaternion(matrix, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_rot_x_45_xyzw(self, device, dtype, atol, rtol):matrix = torch.tensor(((1.0, 0.0, 0.0), (0.0, 0.0, -1.0), (0.0, 1.0, 0.0)), device=device, dtype=dtype)@@ -362,14 +361,14 @@ class TestRotationMatrixToQuaternion:expected = torch.tensor((pi_half2, 0.0, 0.0, pi_half2), device=device, dtype=dtype)with pytest.warns(UserWarning):quaternion = kornia.rotation_matrix_to_quaternion(matrix, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_rot_x_45(self, device, dtype, atol, rtol):matrix = torch.tensor(((1.0, 0.0, 0.0), (0.0, 0.0, -1.0), (0.0, 1.0, 0.0)), device=device, dtype=dtype)pi_half2 = torch.cos(kornia.pi / 4.0).to(device=device, dtype=dtype)expected = torch.tensor((pi_half2, pi_half2, 0.0, 0.0), device=device, dtype=dtype)quaternion = kornia.rotation_matrix_to_quaternion(matrix, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion, expected, atol=atol, rtol=rtol)+ assert_close(quaternion, expected, atol=atol, rtol=rtol)def test_back_and_forth_xyzw(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).eps@@ -377,14 +376,14 @@ class TestRotationMatrixToQuaternion:with pytest.warns(UserWarning):quaternion = kornia.rotation_matrix_to_quaternion(matrix, eps=eps, order=QuaternionCoeffOrder.XYZW)matrix_hat = kornia.quaternion_to_rotation_matrix(quaternion, order=QuaternionCoeffOrder.XYZW)- assert_allclose(matrix, matrix_hat, atol=atol, rtol=rtol)+ assert_close(matrix, matrix_hat, atol=atol, rtol=rtol)def test_back_and_forth(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).epsmatrix = torch.tensor(((1.0, 0.0, 0.0), (0.0, 0.0, -1.0), (0.0, 1.0, 0.0)), device=device, dtype=dtype)quaternion = kornia.rotation_matrix_to_quaternion(matrix, eps=eps, order=QuaternionCoeffOrder.WXYZ)matrix_hat = kornia.quaternion_to_rotation_matrix(quaternion, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(matrix, matrix_hat, atol=atol, rtol=rtol)+ assert_close(matrix, matrix_hat, atol=atol, rtol=rtol)def test_corner_case_xyzw(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).eps@@ -403,7 +402,7 @@ class TestRotationMatrixToQuaternion:with pytest.warns(UserWarning):quaternion = kornia.rotation_matrix_to_quaternion(matrix, eps=eps, order=QuaternionCoeffOrder.XYZW)torch.set_printoptions(precision=10)- assert_allclose(quaternion_true, quaternion, atol=atol, rtol=rtol)+ assert_close(quaternion_true, quaternion, atol=atol, rtol=rtol)def test_corner_case(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).eps@@ -421,7 +420,7 @@ class TestRotationMatrixToQuaternion:)quaternion = kornia.rotation_matrix_to_quaternion(matrix, eps=eps, order=QuaternionCoeffOrder.WXYZ)torch.set_printoptions(precision=10)- assert_allclose(quaternion_true, quaternion, atol=atol, rtol=rtol)+ assert_close(quaternion_true, quaternion, atol=atol, rtol=rtol)def test_gradcheck_xyzw(self, device, dtype):eps = torch.finfo(dtype).eps@@ -455,7 +454,7 @@ class TestRotationMatrixToQuaternion:actual = op_script(quaternion)with pytest.warns(UserWarning):expected = op(quaternion)- assert_allclose(actual, expected)+ assert_close(actual, expected)@pytest.mark.skipif(torch.__version__.startswith('1.6'), reason='JIT Enum not handled.')def test_jit(self, device, dtype):@@ -465,7 +464,7 @@ class TestRotationMatrixToQuaternion:quaternion = torch.tensor((0.0, 0.0, 1.0), device=device, dtype=dtype)actual = op_script(quaternion, eps=eps, order=QuaternionCoeffOrder.WXYZ)expected = op(quaternion, eps=eps, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(actual, expected)+ assert_close(actual, expected)class TestQuaternionToRotationMatrix:@@ -487,26 +486,26 @@ class TestQuaternionToRotationMatrix:expected = torch.tensor(((1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)), device=device, dtype=dtype)with pytest.warns(UserWarning):matrix = kornia.quaternion_to_rotation_matrix(quaternion, order=QuaternionCoeffOrder.XYZW)- assert_allclose(matrix, expected, atol=atol, rtol=rtol)+ assert_close(matrix, expected, atol=atol, rtol=rtol)def test_unit_quaternion(self, device, dtype, atol, rtol):quaternion = torch.tensor((1.0, 0.0, 0.0, 0.0), device=device, dtype=dtype)expected = torch.tensor(((1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)), device=device, dtype=dtype)matrix = kornia.quaternion_to_rotation_matrix(quaternion, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(matrix, expected, atol=atol, rtol=rtol)+ assert_close(matrix, expected, atol=atol, rtol=rtol)def test_x_rotation_xyzw(self, device, dtype, atol, rtol):quaternion = torch.tensor((1.0, 0.0, 0.0, 0.0), device=device, dtype=dtype)expected = torch.tensor(((1.0, 0.0, 0.0), (0.0, -1.0, 0.0), (0.0, 0.0, -1.0)), device=device, dtype=dtype)with pytest.warns(UserWarning):matrix = kornia.quaternion_to_rotation_matrix(quaternion, order=QuaternionCoeffOrder.XYZW)- assert_allclose(matrix, expected, atol=atol, rtol=rtol)+ assert_close(matrix, expected, atol=atol, rtol=rtol)def test_x_rotation(self, device, dtype, atol, rtol):quaternion = torch.tensor((0.0, 1.0, 0.0, 0.0), device=device, dtype=dtype)expected = torch.tensor(((1.0, 0.0, 0.0), (0.0, -1.0, 0.0), (0.0, 0.0, -1.0)), device=device, dtype=dtype)matrix = kornia.quaternion_to_rotation_matrix(quaternion, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(matrix, expected, atol=atol, rtol=rtol)+ assert_close(matrix, expected, atol=atol, rtol=rtol)def test_y_rotation_xyzw(self, device, dtype, atol, rtol):quaternion = torch.tensor((0.0, 1.0, 0.0, 0.0), device=device, dtype=dtype)@@ -514,26 +513,26 @@ class TestQuaternionToRotationMatrix:with pytest.warns(UserWarning):matrix = kornia.quaternion_to_rotation_matrix(quaternion, order=QuaternionCoeffOrder.XYZW)- assert_allclose(matrix, expected, atol=atol, rtol=rtol)+ assert_close(matrix, expected, atol=atol, rtol=rtol)def test_y_rotation(self, device, dtype, atol, rtol):quaternion = torch.tensor((0.0, 0.0, 1.0, 0.0), device=device, dtype=dtype)expected = torch.tensor(((-1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, -1.0)), device=device, dtype=dtype)matrix = kornia.quaternion_to_rotation_matrix(quaternion, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(matrix, expected, atol=atol, rtol=rtol)+ assert_close(matrix, expected, atol=atol, rtol=rtol)def test_z_rotation_xyzw(self, device, dtype, atol, rtol):quaternion = torch.tensor((0.0, 0.0, 1.0, 0.0), device=device, dtype=dtype)expected = torch.tensor(((-1.0, 0.0, 0.0), (0.0, -1.0, 0.0), (0.0, 0.0, 1.0)), device=device, dtype=dtype)with pytest.warns(UserWarning):matrix = kornia.quaternion_to_rotation_matrix(quaternion, order=QuaternionCoeffOrder.XYZW)- assert_allclose(matrix, expected, atol=atol, rtol=rtol)+ assert_close(matrix, expected, atol=atol, rtol=rtol)def test_z_rotation(self, device, dtype, atol, rtol):quaternion = torch.tensor((0.0, 0.0, 0.0, 1.0), device=device, dtype=dtype)expected = torch.tensor(((-1.0, 0.0, 0.0), (0.0, -1.0, 0.0), (0.0, 0.0, 1.0)), device=device, dtype=dtype)matrix = kornia.quaternion_to_rotation_matrix(quaternion, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(matrix, expected, atol=atol, rtol=rtol)+ assert_close(matrix, expected, atol=atol, rtol=rtol)def test_gradcheck_xyzw(self, device, dtype):quaternion = torch.tensor((0.0, 0.0, 0.0, 1.0), device=device, dtype=dtype)@@ -562,14 +561,14 @@ class TestQuaternionToRotationMatrix:op_jit = torch.jit.script(op)quaternion = torch.tensor((0.0, 0.0, 1.0, 0.0), device=device, dtype=dtype)with pytest.warns(UserWarning):- assert_allclose(op(quaternion), op_jit(quaternion))+ assert_close(op(quaternion), op_jit(quaternion))@pytest.mark.skipif(torch.__version__.startswith('1.6'), reason='JIT Enum not handled.')def test_jit(self, device, dtype):op = kornia.geometry.conversions.quaternion_to_rotation_matrixop_jit = torch.jit.script(op)quaternion = torch.tensor((0.0, 0.0, 0.0, 1.0), device=device, dtype=dtype)- assert_allclose(+ assert_close(op(quaternion, order=QuaternionCoeffOrder.WXYZ), op_jit(quaternion, order=QuaternionCoeffOrder.WXYZ))@@ -594,14 +593,14 @@ class TestQuaternionLogToExp:expected = torch.tensor((0.0, 0.0, 0.0, 1.0), device=device, dtype=dtype)with pytest.warns(UserWarning):quaternion_exp = kornia.quaternion_log_to_exp(quaternion_log, eps=eps, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion_exp, expected, atol=atol, rtol=rtol)+ assert_close(quaternion_exp, expected, atol=atol, rtol=rtol)def test_unit_quaternion(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).epsquaternion_log = torch.tensor((0.0, 0.0, 0.0), device=device, dtype=dtype)expected = torch.tensor((1.0, 0.0, 0.0, 0.0), device=device, dtype=dtype)quaternion_exp = kornia.quaternion_log_to_exp(quaternion_log, eps=eps, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion_exp, expected, atol=atol, rtol=rtol)+ assert_close(quaternion_exp, expected, atol=atol, rtol=rtol)def test_pi_quaternion_x_xyzw(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).eps@@ -610,7 +609,7 @@ class TestQuaternionLogToExp:expected = torch.tensor((torch.sin(one), 0.0, 0.0, torch.cos(one)), device=device, dtype=dtype)with pytest.warns(UserWarning):quaternion_exp = kornia.quaternion_log_to_exp(quaternion_log, eps=eps, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion_exp, expected, atol=atol, rtol=rtol)+ assert_close(quaternion_exp, expected, atol=atol, rtol=rtol)def test_pi_quaternion_x(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).eps@@ -618,7 +617,7 @@ class TestQuaternionLogToExp:quaternion_log = torch.tensor((1.0, 0.0, 0.0), device=device, dtype=dtype)expected = torch.tensor((torch.cos(one), torch.sin(one), 0.0, 0.0), device=device, dtype=dtype)quaternion_exp = kornia.quaternion_log_to_exp(quaternion_log, eps=eps, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion_exp, expected, atol=atol, rtol=rtol)+ assert_close(quaternion_exp, expected, atol=atol, rtol=rtol)def test_pi_quaternion_y_xyzw(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).eps@@ -627,7 +626,7 @@ class TestQuaternionLogToExp:expected = torch.tensor((0.0, torch.sin(one), 0.0, torch.cos(one)), device=device, dtype=dtype)with pytest.warns(UserWarning):quaternion_exp = kornia.quaternion_log_to_exp(quaternion_log, eps=eps, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion_exp, expected, atol=atol, rtol=rtol)+ assert_close(quaternion_exp, expected, atol=atol, rtol=rtol)def test_pi_quaternion_y(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).eps@@ -635,7 +634,7 @@ class TestQuaternionLogToExp:quaternion_log = torch.tensor((0.0, 1.0, 0.0), device=device, dtype=dtype)expected = torch.tensor((torch.cos(one), 0.0, torch.sin(one), 0.0), device=device, dtype=dtype)quaternion_exp = kornia.quaternion_log_to_exp(quaternion_log, eps=eps, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion_exp, expected, atol=atol, rtol=rtol)+ assert_close(quaternion_exp, expected, atol=atol, rtol=rtol)def test_pi_quaternion_z_xyzw(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).eps@@ -645,7 +644,7 @@ class TestQuaternionLogToExp:with pytest.warns(UserWarning):quaternion_exp = kornia.quaternion_log_to_exp(quaternion_log, eps=eps, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion_exp, expected, atol=atol, rtol=rtol)+ assert_close(quaternion_exp, expected, atol=atol, rtol=rtol)def test_pi_quaternion_z(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).eps@@ -653,7 +652,7 @@ class TestQuaternionLogToExp:quaternion_log = torch.tensor((0.0, 0.0, 1.0), device=device, dtype=dtype)expected = torch.tensor((torch.cos(one), 0.0, 0.0, torch.sin(one)), device=device, dtype=dtype)quaternion_exp = kornia.quaternion_log_to_exp(quaternion_log, eps=eps, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion_exp, expected, atol=atol, rtol=rtol)+ assert_close(quaternion_exp, expected, atol=atol, rtol=rtol)def test_back_and_forth_xyzw(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).eps@@ -663,7 +662,7 @@ class TestQuaternionLogToExp:quaternion_exp = kornia.quaternion_log_to_exp(quaternion_log, eps=eps, order=QuaternionCoeffOrder.XYZW)with pytest.warns(UserWarning):quaternion_log_hat = kornia.quaternion_exp_to_log(quaternion_exp, eps=eps, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion_log, quaternion_log_hat, atol=atol, rtol=rtol)+ assert_close(quaternion_log, quaternion_log_hat, atol=atol, rtol=rtol)def test_back_and_forth(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).eps@@ -671,7 +670,7 @@ class TestQuaternionLogToExp:quaternion_exp = kornia.quaternion_log_to_exp(quaternion_log, eps=eps, order=QuaternionCoeffOrder.WXYZ)quaternion_log_hat = kornia.quaternion_exp_to_log(quaternion_exp, eps=eps, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion_log, quaternion_log_hat, atol=atol, rtol=rtol)+ assert_close(quaternion_log, quaternion_log_hat, atol=atol, rtol=rtol)def test_gradcheck_xyzw(self, device, dtype):eps = torch.finfo(dtype).eps@@ -702,7 +701,7 @@ class TestQuaternionLogToExp:op_jit = torch.jit.script(op)quaternion = torch.tensor((0.0, 0.0, 1.0), device=device, dtype=dtype)with pytest.warns(UserWarning):- assert_allclose(+ assert_close(op(quaternion, order=QuaternionCoeffOrder.XYZW), op_jit(quaternion, order=QuaternionCoeffOrder.XYZW))@@ -711,7 +710,7 @@ class TestQuaternionLogToExp:op = kornia.geometry.conversions.quaternion_log_to_expop_jit = torch.jit.script(op)quaternion = torch.tensor((0.0, 0.0, 1.0), device=device, dtype=dtype)- assert_allclose(+ assert_close(op(quaternion, order=QuaternionCoeffOrder.WXYZ), op_jit(quaternion, order=QuaternionCoeffOrder.WXYZ))@@ -738,14 +737,14 @@ class TestQuaternionExpToLog:expected = torch.tensor((0.0, 0.0, 0.0), device=device, dtype=dtype)with pytest.warns(UserWarning):quaternion_log = kornia.quaternion_exp_to_log(quaternion_exp, eps=eps, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion_log, expected, atol=atol, rtol=rtol)+ assert_close(quaternion_log, expected, atol=atol, rtol=rtol)def test_unit_quaternion(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).epsquaternion_exp = torch.tensor((1.0, 0.0, 0.0, 0.0), device=device, dtype=dtype)expected = torch.tensor((0.0, 0.0, 0.0), device=device, dtype=dtype)quaternion_log = kornia.quaternion_exp_to_log(quaternion_exp, eps=eps, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion_log, expected, atol=atol, rtol=rtol)+ assert_close(quaternion_log, expected, atol=atol, rtol=rtol)def test_pi_quaternion_x_xyzw(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).eps@@ -753,14 +752,14 @@ class TestQuaternionExpToLog:expected = torch.tensor((kornia.pi / 2.0, 0.0, 0.0), device=device, dtype=dtype)with pytest.warns(UserWarning):quaternion_log = kornia.quaternion_exp_to_log(quaternion_exp, eps=eps, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion_log, expected, atol=atol, rtol=rtol)+ assert_close(quaternion_log, expected, atol=atol, rtol=rtol)def test_pi_quaternion_x(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).epsquaternion_exp = torch.tensor((0.0, 1.0, 0.0, 0.0), device=device, dtype=dtype)expected = torch.tensor((kornia.pi / 2.0, 0.0, 0.0), device=device, dtype=dtype)quaternion_log = kornia.quaternion_exp_to_log(quaternion_exp, eps=eps, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion_log, expected, atol=atol, rtol=rtol)+ assert_close(quaternion_log, expected, atol=atol, rtol=rtol)def test_pi_quaternion_y_xyzw(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).eps@@ -768,14 +767,14 @@ class TestQuaternionExpToLog:expected = torch.tensor((0.0, kornia.pi / 2.0, 0.0), device=device, dtype=dtype)with pytest.warns(UserWarning):quaternion_log = kornia.quaternion_exp_to_log(quaternion_exp, eps=eps, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion_log, expected, atol=atol, rtol=rtol)+ assert_close(quaternion_log, expected, atol=atol, rtol=rtol)def test_pi_quaternion_y(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).epsquaternion_exp = torch.tensor((0.0, 0.0, 1.0, 0.0), device=device, dtype=dtype)expected = torch.tensor((0.0, kornia.pi / 2.0, 0.0), device=device, dtype=dtype)quaternion_log = kornia.quaternion_exp_to_log(quaternion_exp, eps=eps, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion_log, expected, atol=atol, rtol=rtol)+ assert_close(quaternion_log, expected, atol=atol, rtol=rtol)def test_pi_quaternion_z_xyzw(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).eps@@ -783,14 +782,14 @@ class TestQuaternionExpToLog:expected = torch.tensor((0.0, 0.0, kornia.pi / 2.0), device=device, dtype=dtype)with pytest.warns(UserWarning):quaternion_log = kornia.quaternion_exp_to_log(quaternion_exp, eps=eps, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion_log, expected, atol=atol, rtol=rtol)+ assert_close(quaternion_log, expected, atol=atol, rtol=rtol)def test_pi_quaternion_z(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).epsquaternion_exp = torch.tensor((0.0, 0.0, 0.0, 1.0), device=device, dtype=dtype)expected = torch.tensor((0.0, 0.0, kornia.pi / 2.0), device=device, dtype=dtype)quaternion_log = kornia.quaternion_exp_to_log(quaternion_exp, eps=eps, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion_log, expected, atol=atol, rtol=rtol)+ assert_close(quaternion_log, expected, atol=atol, rtol=rtol)def test_back_and_forth_xyzw(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).eps@@ -800,14 +799,14 @@ class TestQuaternionExpToLog:quaternion_log = kornia.quaternion_exp_to_log(quaternion_exp, eps=eps, order=QuaternionCoeffOrder.XYZW)with pytest.warns(UserWarning):quaternion_exp_hat = kornia.quaternion_log_to_exp(quaternion_log, eps=eps, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion_exp, quaternion_exp_hat, atol=atol, rtol=rtol)+ assert_close(quaternion_exp, quaternion_exp_hat, atol=atol, rtol=rtol)def test_back_and_forth(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).epsquaternion_exp = torch.tensor((0.0, 1.0, 0.0, 0.0), device=device, dtype=dtype)quaternion_log = kornia.quaternion_exp_to_log(quaternion_exp, eps=eps, order=QuaternionCoeffOrder.WXYZ)quaternion_exp_hat = kornia.quaternion_log_to_exp(quaternion_log, eps=eps, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion_exp, quaternion_exp_hat, atol=atol, rtol=rtol)+ assert_close(quaternion_exp, quaternion_exp_hat, atol=atol, rtol=rtol)def test_gradcheck_xyzw(self, device, dtype):eps = torch.finfo(dtype).eps@@ -838,7 +837,7 @@ class TestQuaternionExpToLog:op_jit = torch.jit.script(op)quaternion = torch.tensor((0.0, 0.0, 1.0, 0.0), device=device, dtype=dtype)with pytest.warns(UserWarning):- assert_allclose(op(quaternion), op_jit(quaternion), atol=atol, rtol=rtol)+ assert_close(op(quaternion), op_jit(quaternion), atol=atol, rtol=rtol)@pytest.mark.skipif(torch.__version__.startswith('1.6'), reason='JIT Enum not handled.')def test_jit(self, device, dtype, atol, rtol):@@ -848,7 +847,7 @@ class TestQuaternionExpToLog:quaternion = torch.tensor((0.0, 0.0, 0.0, 1.0), device=device, dtype=dtype)actual = op_script(quaternion, eps=torch.finfo(dtype).eps, order=QuaternionCoeffOrder.WXYZ)expected = op(quaternion, eps=torch.finfo(dtype).eps, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(actual, expected, atol=atol, rtol=rtol)+ assert_close(actual, expected, atol=atol, rtol=rtol)class TestAngleAxisToRotationMatrix:@@ -862,7 +861,7 @@ class TestAngleAxisToRotationMatrix:rotation_matrix = kornia.angle_axis_to_rotation_matrix(angle_axis)rotation_matrix_eye = torch.matmul(rotation_matrix, rotation_matrix.transpose(-2, -1))- assert_allclose(rotation_matrix_eye, eye_batch, atol=atol, rtol=rtol)+ assert_close(rotation_matrix_eye, eye_batch, atol=atol, rtol=rtol)# evaluate function gradientangle_axis = tensor_to_gradcheck_var(angle_axis) # to var@@ -893,7 +892,7 @@ class TestAngleAxisToRotationMatrix:rmat = torch.stack((rmat_2, rmat_1), dim=0)rvec = torch.stack((rvec_2, rvec_1), dim=0)- assert_allclose(kornia.angle_axis_to_rotation_matrix(rvec), rmat, atol=atol, rtol=rtol)+ assert_close(kornia.angle_axis_to_rotation_matrix(rvec), rmat, atol=atol, rtol=rtol)class TestRotationMatrixToAngleAxis:@@ -907,7 +906,7 @@ class TestRotationMatrixToAngleAxis:eye_batch = create_eye_batch(batch_size, 3, device=device, dtype=dtype)rotation_matrix_eye = torch.matmul(rotation_matrix, rotation_matrix.transpose(-2, -1))# This didn't pass with atol=0.001, rtol=0.001 for float16 Cuda 11.2 GeForce 1080 Ti- assert_allclose(rotation_matrix_eye, eye_batch, atol=atol * 10.0, rtol=rtol * 10.0)+ assert_close(rotation_matrix_eye, eye_batch, atol=atol * 10.0, rtol=rtol * 10.0)# evaluate function gradientrotation_matrix = tensor_to_gradcheck_var(rotation_matrix) # to var@@ -938,11 +937,11 @@ class TestRotationMatrixToAngleAxis:rmat = torch.stack((rmat_2, rmat_1), dim=0)rvec = torch.stack((rvec_2, rvec_1), dim=0)- assert_allclose(kornia.rotation_matrix_to_angle_axis(rmat), rvec, atol=atol, rtol=rtol)+ assert_close(kornia.rotation_matrix_to_angle_axis(rmat), rvec, atol=atol, rtol=rtol)def test_pi():- assert_allclose(kornia.pi, 3.141592)+ assert_close(kornia.pi.item(), 3.141592)@pytest.mark.parametrize("batch_shape", [(2, 3), (1, 2, 3), (2, 3, 3), (5, 5, 3)])@@ -955,7 +954,7 @@ def test_rad2deg(batch_shape, device, dtype):x_deg_to_rad = kornia.deg2rad(x_deg)# compute error- assert_allclose(x_rad, x_deg_to_rad)+ assert_close(x_rad, x_deg_to_rad)# evaluate function gradientassert gradcheck(kornia.rad2deg, (tensor_to_gradcheck_var(x_rad),), raise_exception=True)@@ -970,7 +969,7 @@ def test_deg2rad(batch_shape, device, dtype, atol, rtol):x_rad = kornia.deg2rad(x_deg)x_rad_to_deg = kornia.rad2deg(x_rad)- assert_allclose(x_deg, x_rad_to_deg, atol=atol, rtol=rtol)+ assert_close(x_deg, x_rad_to_deg, atol=atol, rtol=rtol)eps = torch.finfo(dtype).epsassert gradcheck(kornia.deg2rad, (tensor_to_gradcheck_var(x_deg),), raise_exception=True)@@ -994,8 +993,8 @@ class TestPolCartConversions:x_pol2cart, y_pol2cart = kornia.pol2cart(rho, phi)rho_pol2cart, phi_pol2cart = kornia.cart2pol(x_pol2cart, y_pol2cart, 0)- assert_allclose(rho, rho_pol2cart)- assert_allclose(phi, phi_pol2cart)+ assert_close(rho, rho_pol2cart)+ assert_close(phi, phi_pol2cart)assert gradcheck(kornia.pol2cart, (tensor_to_gradcheck_var(rho), tensor_to_gradcheck_var(phi)), raise_exception=True@@ -1013,8 +1012,8 @@ class TestPolCartConversions:rho_cart2pol, phi_cart2pol = kornia.cart2pol(x, y, 0)x_cart2pol, y_cart2pol = kornia.pol2cart(rho_cart2pol, phi_cart2pol)- assert_allclose(x, x_cart2pol)- assert_allclose(y, y_cart2pol)+ assert_close(x, x_cart2pol)+ assert_close(y, y_cart2pol)assert gradcheck(kornia.cart2pol, (tensor_to_gradcheck_var(x), tensor_to_gradcheck_var(y)), raise_exception=True@@ -1044,7 +1043,7 @@ class TestConvertPointsToHomogeneous:# to euclideanpoints = kornia.convert_points_to_homogeneous(points_h)- assert_allclose(points, expected, atol=1e-4, rtol=1e-4)+ assert_close(points, expected, atol=1e-4, rtol=1e-4)def test_convert_points_batch(self, device, dtype):# generate input data@@ -1056,7 +1055,7 @@ class TestConvertPointsToHomogeneous:# to euclideanpoints = kornia.convert_points_to_homogeneous(points_h)- assert_allclose(points, expected, atol=1e-4, rtol=1e-4)+ assert_close(points, expected, atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("batch_shape", [(2, 3), (1, 2, 3), (2, 3, 3), (5, 5, 3)])def test_gradcheck(self, batch_shape, device, dtype):@@ -1070,7 +1069,7 @@ class TestConvertPointsToHomogeneous:op = kornia.geometry.conversions.convert_points_to_homogeneousop_jit = torch.jit.script(op)points_h = torch.zeros(1, 2, 3, device=device, dtype=dtype)- assert_allclose(op(points_h), op_jit(points_h))+ assert_close(op(points_h), op_jit(points_h))class TestConvertAtoH:@@ -1084,7 +1083,7 @@ class TestConvertAtoH:# to euclideanH = kornia.geometry.conversions.convert_affinematrix_to_homography(A)- assert_allclose(H, expected)+ assert_close(H, expected)@pytest.mark.parametrize("batch_shape", [(10, 2, 3), (16, 2, 3)])def test_gradcheck(self, batch_shape, device, dtype):@@ -1098,7 +1097,7 @@ class TestConvertAtoH:op = kornia.geometry.conversions.convert_affinematrix_to_homographyop_jit = torch.jit.script(op)points_h = torch.zeros(1, 2, 3, device=device, dtype=dtype)- assert_allclose(op(points_h), op_jit(points_h))+ assert_close(op(points_h), op_jit(points_h))class TestConvertPointsFromHomogeneous:@@ -1122,7 +1121,7 @@ class TestConvertPointsFromHomogeneous:# to euclideanpoints = kornia.convert_points_from_homogeneous(points_h)- assert_allclose(points, expected, atol=1e-4, rtol=1e-4)+ assert_close(points, expected, atol=1e-4, rtol=1e-4)def test_points_batch(self, device, dtype):# generate input data@@ -1132,7 +1131,7 @@ class TestConvertPointsFromHomogeneous:# to euclideanpoints = kornia.convert_points_from_homogeneous(points_h)- assert_allclose(points, expected, atol=1e-4, rtol=1e-4)+ assert_close(points, expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):points_h = torch.ones(1, 10, 3, device=device, dtype=dtype)@@ -1154,7 +1153,7 @@ class TestConvertPointsFromHomogeneous:op = kornia.geometry.conversions.convert_points_from_homogeneousop_jit = torch.jit.script(op)points_h = torch.zeros(1, 2, 3, device=device, dtype=dtype)- assert_allclose(op(points_h), op_jit(points_h))+ assert_close(op(points_h), op_jit(points_h))class TestNormalizePixelCoordinates:@@ -1169,7 +1168,7 @@ class TestNormalizePixelCoordinates:grid_norm = kornia.normalize_pixel_coordinates(grid, height, width, eps=eps)- assert_allclose(grid_norm, expected, atol=atol, rtol=rtol)+ assert_close(grid_norm, expected, atol=atol, rtol=rtol)def test_list(self, device, dtype, atol, rtol):eps = torch.finfo(dtype).eps@@ -1184,7 +1183,7 @@ class TestNormalizePixelCoordinates:grid_norm = kornia.normalize_pixel_coordinates(grid, height, width, eps=eps)- assert_allclose(grid_norm, expected, atol=atol, rtol=rtol)+ assert_close(grid_norm, expected, atol=atol, rtol=rtol)def test_jit(self, device, dtype):op = kornia.geometry.conversions.normalize_pixel_coordinates@@ -1195,7 +1194,7 @@ class TestNormalizePixelCoordinates:actual = op_script(grid, height, width)expected = op(grid, height, width)- assert_allclose(actual, expected)+ assert_close(actual, expected)class TestDenormalizePixelCoordinates:@@ -1209,7 +1208,7 @@ class TestDenormalizePixelCoordinates:grid_norm = kornia.denormalize_pixel_coordinates(grid, height, width)- assert_allclose(grid_norm, expected, atol=1e-4, rtol=1e-4)+ assert_close(grid_norm, expected, atol=1e-4, rtol=1e-4)def test_list(self, device, dtype):height, width = 3, 4@@ -1223,7 +1222,7 @@ class TestDenormalizePixelCoordinates:grid_norm = kornia.denormalize_pixel_coordinates(grid, height, width)- assert_allclose(grid_norm, expected, atol=1e-4, rtol=1e-4)+ assert_close(grid_norm, expected, atol=1e-4, rtol=1e-4)def test_jit(self, device, dtype):op = kornia.geometry.conversions.denormalize_pixel_coordinates@@ -1235,4 +1234,4 @@ class TestDenormalizePixelCoordinates:actual = op_script(grid, height, width)expected = op(grid, height, width)- assert_allclose(actual, expected)+ assert_close(actual, expected)diff --git a/test/geometry/test_depth.py b/test/geometry/test_depth.pyindex 253566c26..e5a9e4084 100644--- a/test/geometry/test_depth.py+++ b/test/geometry/test_depth.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestDepthTo3d:@@ -52,7 +52,7 @@ class TestDepthTo3d:)points3d = kornia.depth_to_3d(depth, camera_matrix) # default is normalize_points=False- assert_allclose(points3d, points3d_expected, atol=1e-4, rtol=1e-4)+ assert_close(points3d, points3d_expected, atol=1e-4, rtol=1e-4)def test_unproject_normalized(self, device, dtype):# this is for normalize_points=True@@ -90,7 +90,7 @@ class TestDepthTo3d:)points3d = kornia.depth_to_3d(depth, camera_matrix, normalize_points=True)- assert_allclose(points3d, points3d_expected, atol=1e-4, rtol=1e-4)+ assert_close(points3d, points3d_expected, atol=1e-4, rtol=1e-4)def test_unproject_and_project(self, device, dtype):depth = 2 * torch.tensor(@@ -102,7 +102,7 @@ class TestDepthTo3d:points3d = kornia.depth_to_3d(depth, camera_matrix)points2d = kornia.project_points(points3d.permute(0, 2, 3, 1), camera_matrix[:, None, None])points2d_expected = kornia.create_meshgrid(4, 3, False, device=device).to(dtype=dtype)- assert_allclose(points2d, points2d_expected, atol=1e-4, rtol=1e-4)+ assert_close(points2d, points2d_expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):# generate input data@@ -161,7 +161,7 @@ class TestDepthToNormals:)normals = kornia.depth_to_normals(depth, camera_matrix) # default is normalize_points=False- assert_allclose(normals, normals_expected, 1e-3, 1e-3)+ assert_close(normals, normals_expected, rtol=1e-3, atol=1e-3)def test_simple_normalized(self, device, dtype):# this is for default normalize_points=False@@ -199,7 +199,7 @@ class TestDepthToNormals:)normals = kornia.depth_to_normals(depth, camera_matrix, normalize_points=True)- assert_allclose(normals, normals_expected, 1e-3, 1e-3)+ assert_close(normals, normals_expected, rtol=1e-3, atol=1e-3)def test_gradcheck(self, device, dtype):# generate input data@@ -262,7 +262,7 @@ class TestWarpFrameDepth:image_dst = kornia.warp_frame_depth(image_src, depth_dst, src_trans_dst, camera_matrix) # default is normalize_points=False- assert_allclose(image_dst, image_dst_expected, 1e-3, 1e-3)+ assert_close(image_dst, image_dst_expected, rtol=1e-3, atol=1e-3)def test_translation_normalized(self, device, dtype):# this is for normalize_points=True@@ -301,7 +301,7 @@ class TestWarpFrameDepth:)image_dst = kornia.warp_frame_depth(image_src, depth_dst, src_trans_dst, camera_matrix, normalize_points=True)- assert_allclose(image_dst, image_dst_expected, 1e-3, 1e-3)+ assert_close(image_dst, image_dst_expected, rtol=1e-3, atol=1e-3)def test_gradcheck(self, device, dtype):image_src = torch.rand(1, 3, 3, 4, device=device, dtype=dtype)diff --git a/test/geometry/test_depth_warper.py b/test/geometry/test_depth_warper.pyindex 5946d8728..adce30dc0 100644--- a/test/geometry/test_depth_warper.py+++ b/test/geometry/test_depth_warper.py@@ -1,11 +1,11 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utilsfrom kornia.geometry.conversions import normalize_pixel_coordinates+from kornia.testing import assert_closeclass TestDepthWarper:@@ -47,7 +47,7 @@ class TestDepthWarper:dst_proj_src_expected[..., 0, -2] += pinhole_src.cxdst_proj_src_expected[..., 1, -2] += pinhole_src.cydst_proj_src_expected[..., 0, -1] += 1.0 # offset to x-axis- assert_allclose(dst_proj_src, dst_proj_src_expected)+ assert_close(dst_proj_src, dst_proj_src_expected)@pytest.mark.parametrize("batch_size", (1, 2))def test_warp_grid_offset_x1_depth1(self, batch_size, device, dtype):@@ -70,9 +70,9 @@ class TestDepthWarper:grid_norm = normalize_pixel_coordinates(grid, height, width)# check offset in x-axis- assert_allclose(grid_warped[..., -2, 0], grid_norm[..., -1, 0].repeat(batch_size, 1), atol=1e-4, rtol=1e-4)+ assert_close(grid_warped[..., -2, 0], grid_norm[..., -1, 0].repeat(batch_size, 1), atol=1e-4, rtol=1e-4)# check that y-axis remain the same- assert_allclose(grid_warped[..., -1, 1], grid_norm[..., -1, 1].repeat(batch_size, 1), rtol=1e-4, atol=1e-4)+ assert_close(grid_warped[..., -1, 1], grid_norm[..., -1, 1].repeat(batch_size, 1), rtol=1e-4, atol=1e-4)@pytest.mark.parametrize("batch_size", (1, 2))def test_warp_grid_offset_x1y1_depth1(self, batch_size, device, dtype):@@ -96,11 +96,9 @@ class TestDepthWarper:grid_norm = normalize_pixel_coordinates(grid, height, width)# check offset in x-axis- assert_allclose(grid_warped[..., -2, 0], grid_norm[..., -1, 0].repeat(batch_size, 1), atol=1e-4, rtol=1e-4)+ assert_close(grid_warped[..., -2, 0], grid_norm[..., -1, 0].repeat(batch_size, 1), atol=1e-4, rtol=1e-4)# check that y-axis remain the same- assert_allclose(- grid_warped[..., -2, :, 1], grid_norm[..., -1, :, 1].repeat(batch_size, 1), rtol=1e-4, atol=1e-4- )+ assert_close(grid_warped[..., -2, :, 1], grid_norm[..., -1, :, 1].repeat(batch_size, 1), rtol=1e-4, atol=1e-4)@pytest.mark.parametrize("batch_size", (1, 2))def test_warp_tensor_offset_x1y1(self, batch_size, device, dtype):@@ -127,7 +125,7 @@ class TestDepthWarper:patch_src = warper(depth_src, patch_dst)# compare patches- assert_allclose(patch_dst[..., 1:, 1:], patch_src[..., :2, :4], atol=1e-4, rtol=1e-4)+ assert_close(patch_dst[..., 1:, 1:], patch_src[..., :2, :4], atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("batch_size", (1, 2))def test_compute_projection(self, batch_size, device, dtype):diff --git a/test/geometry/test_homography.py b/test/geometry/test_homography.pyindex 7401604bc..f731cb10f 100644--- a/test/geometry/test_homography.py+++ b/test/geometry/test_homography.py@@ -3,10 +3,10 @@ import randomimport pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniafrom kornia.geometry.homography import find_homography_dlt, find_homography_dlt_iterated+from kornia.testing import assert_closeclass TestFindHomographyDLT:@@ -43,7 +43,7 @@ class TestFindHomographyDLT:H_noweights = find_homography_dlt(points1, points2, None)H_withweights = find_homography_dlt(points1, points2, weights)assert H_noweights.shape == (B, 3, 3) and H_withweights.shape == (B, 3, 3)- assert_allclose(H_noweights, H_withweights, rtol=1e-3, atol=1e-4)+ assert_close(H_noweights, H_withweights, rtol=1e-3, atol=1e-4)@pytest.mark.parametrize("batch_size", [1, 2, 5])def test_clean_points(self, batch_size, device, dtype):@@ -59,7 +59,7 @@ class TestFindHomographyDLT:# compute transform from source to targetdst_homo_src = find_homography_dlt(points_src, points_dst, weights)- assert_allclose(kornia.transform_points(dst_homo_src, points_src), points_dst, rtol=1e-3, atol=1e-4)+ assert_close(kornia.transform_points(dst_homo_src, points_src), points_dst, rtol=1e-3, atol=1e-4)@pytest.mark.grad@pytest.mark.skipif(torch.__version__ < '1.7', reason="pytorch bug of incopatible types: #33546 fixed in v1.7")@@ -133,7 +133,7 @@ class TestFindHomographyDLTIter:# compute transform from source to targetdst_homo_src = find_homography_dlt_iterated(points_src, points_dst, weights, 10)- assert_allclose(kornia.transform_points(dst_homo_src, points_src), points_dst, rtol=1e-3, atol=1e-4)+ assert_close(kornia.transform_points(dst_homo_src, points_src), points_dst, rtol=1e-3, atol=1e-4)@pytest.mark.grad@pytest.mark.skipif(torch.__version__ < '1.7', reason="pytorch bug of incopatible types: #33546 fixed in v1.7")@@ -200,6 +200,6 @@ class TestFindHomographyDLTIter:# compute transform from source to targetdst_homo_src = find_homography_dlt_iterated(points_src, points_dst, weights, 0.5, 10)- assert_allclose(+ assert_close(kornia.transform_points(dst_homo_src, points_src[:, :-1]), points_dst[:, :-1], rtol=1e-3, atol=1e-3)diff --git a/test/geometry/test_linalg.py b/test/geometry/test_linalg.pyindex bd7acc4f0..0a3d21839 100644--- a/test/geometry/test_linalg.py+++ b/test/geometry/test_linalg.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closedef identity_matrix(batch_size, device, dtype):@@ -100,7 +100,7 @@ class TestTransformPoints:points_dst_to_src = kornia.transform_points(src_homo_dst, points_dst)# projected should be equal as initial- assert_allclose(points_src, points_dst_to_src, atol=1e-4, rtol=1e-4)+ assert_close(points_src, points_dst_to_src, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):# generate input data@@ -120,7 +120,7 @@ class TestTransformPoints:op_script = torch.jit.script(op)actual = op_script(transform, points)expected = op(transform, points)- assert_allclose(actual, expected, atol=1e-4, rtol=1e-4)+ assert_close(actual, expected, atol=1e-4, rtol=1e-4)class TestTransformBoxes:@@ -133,7 +133,7 @@ class TestTransformBoxes:trans_mat = torch.tensor([[[-1.0, 0.0, 512.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]], device=device, dtype=dtype)out = kornia.transform_boxes(trans_mat, boxes)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)def test_transform_multiple_boxes(self, device, dtype):@@ -179,7 +179,7 @@ class TestTransformBoxes:)out = kornia.transform_boxes(trans_mat, boxes)- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)def test_transform_boxes_wh(self, device, dtype):@@ -208,7 +208,7 @@ class TestTransformBoxes:trans_mat = torch.tensor([[[-1.0, 0.0, 512.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]], device=device, dtype=dtype)out = kornia.transform_boxes(trans_mat, boxes, mode='xywh')- assert_allclose(out, expected, atol=1e-4, rtol=1e-4)+ assert_close(out, expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):@@ -236,7 +236,7 @@ class TestTransformBoxes:args = (boxes, trans_mat)op = kornia.geometry.transform_pointsop_jit = torch.jit.script(op)- assert_allclose(op(*args), op_jit(*args))+ assert_close(op(*args), op_jit(*args))class TestComposeTransforms:@@ -247,7 +247,7 @@ class TestComposeTransforms:trans_12[..., :3, -1] += offset # add offset to translation vectortrans_02 = kornia.compose_transformations(trans_01, trans_12)- assert_allclose(trans_02, trans_12, atol=1e-4, rtol=1e-4)+ assert_close(trans_02, trans_12, atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("batch_size", [1, 2, 5])def test_translation_Bx4x4(self, batch_size, device, dtype):@@ -257,7 +257,7 @@ class TestComposeTransforms:trans_12[..., :3, -1] += offset # add offset to translation vectortrans_02 = kornia.compose_transformations(trans_01, trans_12)- assert_allclose(trans_02, trans_12, atol=1e-4, rtol=1e-4)+ assert_close(trans_02, trans_12, atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("batch_size", [1, 2, 5])def test_gradcheck(self, batch_size, device, dtype):@@ -277,7 +277,7 @@ class TestInverseTransformation:trans_10 = kornia.inverse_transformation(trans_01)trans_01_hat = kornia.inverse_transformation(trans_10)- assert_allclose(trans_01, trans_01_hat, atol=1e-4, rtol=1e-4)+ assert_close(trans_01, trans_01_hat, atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("batch_size", [1, 2, 5])def test_translation_Bx4x4(self, batch_size, device, dtype):@@ -287,7 +287,7 @@ class TestInverseTransformation:trans_10 = kornia.inverse_transformation(trans_01)trans_01_hat = kornia.inverse_transformation(trans_10)- assert_allclose(trans_01, trans_01_hat, atol=1e-4, rtol=1e-4)+ assert_close(trans_01, trans_01_hat, atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("batch_size", [1, 2, 5])def test_rotation_translation_Bx4x4(self, batch_size, device, dtype):@@ -302,7 +302,7 @@ class TestInverseTransformation:trans_10 = kornia.inverse_transformation(trans_01)trans_01_hat = kornia.inverse_transformation(trans_10)- assert_allclose(trans_01, trans_01_hat, atol=1e-4, rtol=1e-4)+ assert_close(trans_01, trans_01_hat, atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("batch_size", [1, 2, 5])def test_gradcheck(self, batch_size, device, dtype):@@ -320,7 +320,7 @@ class TestRelativeTransformation:trans_12 = kornia.relative_transformation(trans_01, trans_02)trans_02_hat = kornia.compose_transformations(trans_01, trans_12)- assert_allclose(trans_02_hat, trans_02, atol=1e-4, rtol=1e-4)+ assert_close(trans_02_hat, trans_02, atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("batch_size", [1, 2, 5])def test_rotation_translation_Bx4x4(self, batch_size, device, dtype):@@ -336,7 +336,7 @@ class TestRelativeTransformation:trans_12 = kornia.relative_transformation(trans_01, trans_02)trans_02_hat = kornia.compose_transformations(trans_01, trans_12)- assert_allclose(trans_02_hat, trans_02, atol=1e-4, rtol=1e-4)+ assert_close(trans_02_hat, trans_02, atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("batch_size", [1, 2, 5])def test_gradcheck(self, batch_size, device, dtype):@@ -366,7 +366,7 @@ class TestTransformLAFs:lafs_dst_to_src = kornia.perspective_transform_lafs(src_homo_dst, lafs_dst)# projected should be equal as initial- assert_allclose(lafs_src, lafs_dst_to_src)+ assert_close(lafs_src, lafs_dst_to_src)def test_gradcheck(self, device, dtype):# generate input datadiff --git a/test/geometry/test_perspective.py b/test/geometry/test_perspective.pyindex 0cd0049bb..0a031ab9f 100644--- a/test/geometry/test_perspective.py+++ b/test/geometry/test_perspective.py@@ -1,9 +1,8 @@import torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia-from kornia.testing import tensor_to_gradcheck_var+from kornia.testing import assert_close, tensor_to_gradcheck_varclass TestProjectPoints:@@ -33,7 +32,7 @@ class TestProjectPoints:)point_2d = kornia.geometry.camera.project_points(point_3d, camera_matrix)point_3d_hat = kornia.geometry.camera.unproject_points(point_2d, depth, camera_matrix)- assert_allclose(point_3d, point_3d_hat, atol=1e-4, rtol=1e-4)+ assert_close(point_3d, point_3d_hat, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):# TODO: point [0, 0, 0] crashes@@ -50,7 +49,7 @@ class TestProjectPoints:camera_matrix = torch.eye(3, device=device, dtype=dtype).expand(1, -1, -1)op = kornia.geometry.camera.project_pointsop_jit = torch.jit.script(op)- assert_allclose(op(points_3d, camera_matrix), op_jit(points_3d, camera_matrix))+ assert_close(op(points_3d, camera_matrix), op_jit(points_3d, camera_matrix))class TestUnprojectPoints:@@ -81,7 +80,7 @@ class TestUnprojectPoints:camera_matrix = torch.tensor([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]], device=device, dtype=dtype)expected = torch.tensor([[0.0, 0.0, 2.0]], device=device, dtype=dtype)actual = kornia.geometry.camera.unproject_points(point_2d, depth, camera_matrix)- assert_allclose(actual, expected, atol=1e-4, rtol=1e-4)+ assert_close(actual, expected, atol=1e-4, rtol=1e-4)def test_unproject_center_normalize(self, device, dtype):point_2d = torch.tensor([[0.0, 0.0]], device=device, dtype=dtype)@@ -89,7 +88,7 @@ class TestUnprojectPoints:camera_matrix = torch.tensor([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]], device=device, dtype=dtype)expected = torch.tensor([[0.0, 0.0, 2.0]], device=device, dtype=dtype)actual = kornia.geometry.camera.unproject_points(point_2d, depth, camera_matrix, True)- assert_allclose(actual, expected, atol=1e-4, rtol=1e-4)+ assert_close(actual, expected, atol=1e-4, rtol=1e-4)def test_unproject_and_project(self, device, dtype):point_2d = torch.tensor([[0.0, 0.0]], device=device, dtype=dtype)@@ -97,7 +96,7 @@ class TestUnprojectPoints:camera_matrix = torch.tensor([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]], device=device, dtype=dtype)point_3d = kornia.geometry.camera.unproject_points(point_2d, depth, camera_matrix)point_2d_hat = kornia.geometry.camera.project_points(point_3d, camera_matrix)- assert_allclose(point_2d, point_2d_hat, atol=1e-4, rtol=1e-4)+ assert_close(point_2d, point_2d_hat, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):points_2d = torch.zeros(1, 2, device=device, dtype=dtype)@@ -119,4 +118,4 @@ class TestUnprojectPoints:args = (points_2d, depth, camera_matrix)op = kornia.geometry.camera.unproject_pointsop_jit = torch.jit.script(op)- assert_allclose(op(*args), op_jit(*args))+ assert_close(op(*args), op_jit(*args))diff --git a/test/geometry/test_pinhole.py b/test/geometry/test_pinhole.pyindex 9f10a722c..234f72d94 100644--- a/test/geometry/test_pinhole.py+++ b/test/geometry/test_pinhole.py@@ -1,7 +1,7 @@import torch-from torch.testing import assert_allcloseimport kornia+from kornia.testing import assert_closeclass TestPinholeCamera:@@ -135,20 +135,20 @@ class TestPinholeCamera:pinhole = kornia.PinholeCamera(intrinsics, extrinsics, height, width)pinhole_scale = pinhole.scale(scale_factor)- assert_allclose(+ assert_close(pinhole_scale.intrinsics[..., 0, 0], pinhole.intrinsics[..., 0, 0] * scale_val, atol=1e-4, rtol=1e-4) # fx- assert_allclose(+ assert_close(pinhole_scale.intrinsics[..., 1, 1], pinhole.intrinsics[..., 1, 1] * scale_val, atol=1e-4, rtol=1e-4) # fy- assert_allclose(+ assert_close(pinhole_scale.intrinsics[..., 0, 2], pinhole.intrinsics[..., 0, 2] * scale_val, atol=1e-4, rtol=1e-4) # cx- assert_allclose(+ assert_close(pinhole_scale.intrinsics[..., 1, 2], pinhole.intrinsics[..., 1, 2] * scale_val, atol=1e-4, rtol=1e-4) # cy- assert_allclose(pinhole_scale.height, pinhole.height * scale_val, atol=1e-4, rtol=1e-4)- assert_allclose(pinhole_scale.width, pinhole.width * scale_val, atol=1e-4, rtol=1e-4)+ assert_close(pinhole_scale.height, pinhole.height * scale_val, atol=1e-4, rtol=1e-4)+ assert_close(pinhole_scale.width, pinhole.width * scale_val, atol=1e-4, rtol=1e-4)def test_pinhole_camera_scale_inplace(self, device, dtype):batch_size = 2@@ -167,20 +167,20 @@ class TestPinholeCamera:pinhole_scale = pinhole.clone()pinhole_scale.scale_(scale_factor)- assert_allclose(+ assert_close(pinhole_scale.intrinsics[..., 0, 0], pinhole.intrinsics[..., 0, 0] * scale_val, atol=1e-4, rtol=1e-4) # fx- assert_allclose(+ assert_close(pinhole_scale.intrinsics[..., 1, 1], pinhole.intrinsics[..., 1, 1] * scale_val, atol=1e-4, rtol=1e-4) # fy- assert_allclose(+ assert_close(pinhole_scale.intrinsics[..., 0, 2], pinhole.intrinsics[..., 0, 2] * scale_val, atol=1e-4, rtol=1e-4) # cx- assert_allclose(+ assert_close(pinhole_scale.intrinsics[..., 1, 2], pinhole.intrinsics[..., 1, 2] * scale_val, atol=1e-4, rtol=1e-4) # cy- assert_allclose(pinhole_scale.height, pinhole.height * scale_val, atol=1e-4, rtol=1e-4)- assert_allclose(pinhole_scale.width, pinhole.width * scale_val, atol=1e-4, rtol=1e-4)+ assert_close(pinhole_scale.height, pinhole.height * scale_val, atol=1e-4, rtol=1e-4)+ assert_close(pinhole_scale.width, pinhole.width * scale_val, atol=1e-4, rtol=1e-4)'''@pytest.mark.parametrize("batch_size", [1, 2, 5, 6])@@ -191,7 +191,7 @@ def test_scale_pinhole(batch_size, device_type):scales = torch.rand(batch_size, device=device, dtype=dtype)pinholes_scale = kornia.scale_pinhole(pinholes, scales)- assert_allclose(+ assert_close(pinholes_scale[..., :6] / scales.unsqueeze(-1), pinholes[..., :6])# evaluate function gradient@@ -251,11 +251,11 @@ def test_inverse_pinhole_matrix(batch_size, device_type):pinhole_matrix = kornia.inverse_pinhole_matrix(pinhole)ones = torch.ones(batch_size)- assert_allclose(pinhole_matrix[:, 0, 0], (1. / fx) * ones)- assert_allclose(pinhole_matrix[:, 1, 1], (1. / fy) * ones)- assert_allclose(+ assert_close(pinhole_matrix[:, 0, 0], (1. / fx) * ones)+ assert_close(pinhole_matrix[:, 1, 1], (1. / fy) * ones)+ assert_close(pinhole_matrix[:, 0, 2], (-1. * cx / fx) * ones)- assert_allclose(+ assert_close(pinhole_matrix[:, 1, 2], (-1. * cy / fx) * ones)# functional@@ -304,7 +304,7 @@ def test_homography_i_H_ref(batch_size, device_type):# compute homography from i to refref_H_i = kornia.homography_i_H_ref(pinhole_ref, pinhole_i) + eps- assert_allclose(i_H_ref_inv, ref_H_i)+ assert_close(i_H_ref_inv, ref_H_i)# evaluate function gradientassert gradcheck(kornia.homography_i_H_ref,diff --git a/test/geometry/transform/crop/test_crop2d.py b/test/geometry/transform/crop/test_crop2d.pyindex d7d769619..dcb5778b0 100644--- a/test/geometry/transform/crop/test_crop2d.py+++ b/test/geometry/transform/crop/test_crop2d.py@@ -1,9 +1,9 @@import torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestBoundingBoxInferring:@@ -36,7 +36,7 @@ class TestBoundingBoxInferring:actual = op_script(boxes)expected = op(boxes)- assert_allclose(actual, expected)+ assert_close(actual, expected)class TestCropAndResize:@@ -55,7 +55,7 @@ class TestCropAndResize:# default should use align_coners Truepatches = kornia.crop_and_resize(inp, boxes, (height, width))- assert_allclose(patches, expected, rtol=1e-4, atol=1e-4)+ assert_close(patches, expected, rtol=1e-4, atol=1e-4)def test_align_corners_false(self, device, dtype):inp = torch.tensor(@@ -70,7 +70,7 @@ class TestCropAndResize:boxes = torch.tensor([[[1.0, 1.0], [2.0, 1.0], [2.0, 2.0], [1.0, 2.0]]], device=device, dtype=dtype) # 1x4x2patches = kornia.crop_and_resize(inp, boxes, (height, width), align_corners=False)- assert_allclose(patches, expected, rtol=1e-4, atol=1e-4)+ assert_close(patches, expected, rtol=1e-4, atol=1e-4)def test_crop_batch(self, device, dtype):inp = torch.tensor(@@ -93,7 +93,7 @@ class TestCropAndResize:) # 2x4x2patches = kornia.crop_and_resize(inp, boxes, (2, 2))- assert_allclose(patches, expected, rtol=1e-4, atol=1e-4)+ assert_close(patches, expected, rtol=1e-4, atol=1e-4)def test_crop_batch_broadcast(self, device, dtype):inp = torch.tensor(@@ -112,7 +112,7 @@ class TestCropAndResize:boxes = torch.tensor([[[1.0, 1.0], [2.0, 1.0], [2.0, 2.0], [1.0, 2.0]]], device=device, dtype=dtype) # 1x4x2patches = kornia.crop_and_resize(inp, boxes, (2, 2))- assert_allclose(patches, expected, rtol=1e-4, atol=1e-4)+ assert_close(patches, expected, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device, dtype):img = torch.rand(1, 2, 5, 4, device=device, dtype=dtype)@@ -138,7 +138,7 @@ class TestCropAndResize:crop_height, crop_width = 4, 2actual = op_script(img, boxes, (crop_height, crop_width))expected = op(img, boxes, (crop_height, crop_width))- assert_allclose(actual, expected, rtol=1e-4, atol=1e-4)+ assert_close(actual, expected, rtol=1e-4, atol=1e-4)class TestCenterCrop:@@ -152,7 +152,7 @@ class TestCenterCrop:expected = torch.tensor([[[[5.0, 6.0, 7.0, 8.0], [9.0, 10.0, 11.0, 12.0]]]], device=device, dtype=dtype)out_crop = kornia.center_crop(inp, (2, 4))- assert_allclose(out_crop, expected, rtol=1e-4, atol=1e-4)+ assert_close(out_crop, expected, rtol=1e-4, atol=1e-4)def test_center_crop_h4_w2(self, device, dtype):inp = torch.tensor(@@ -165,7 +165,7 @@ class TestCenterCrop:expected = torch.tensor([[[[2.0, 3.0], [6.0, 7.0], [10.0, 11.0], [14.0, 15.0]]]], device=device, dtype=dtype)out_crop = kornia.center_crop(inp, (height, width))- assert_allclose(out_crop, expected, rtol=1e-4, atol=1e-4)+ assert_close(out_crop, expected, rtol=1e-4, atol=1e-4)def test_center_crop_h4_w2_batch(self, device, dtype):inp = torch.tensor(@@ -187,7 +187,7 @@ class TestCenterCrop:)out_crop = kornia.center_crop(inp, (4, 2))- assert_allclose(out_crop, expected, rtol=1e-4, atol=1e-4)+ assert_close(out_crop, expected, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device, dtype):img = torch.rand(1, 2, 5, 4, device=device, dtype=dtype)@@ -204,7 +204,7 @@ class TestCenterCrop:actual = op_script(img, (4, 2))expected = op(img, (4, 2))- assert_allclose(actual, expected, rtol=1e-4, atol=1e-4)+ assert_close(actual, expected, rtol=1e-4, atol=1e-4)def test_jit_trace(self, device, dtype):# Define script@@ -217,7 +217,7 @@ class TestCenterCrop:# Runactual = op_trace(img, (torch.tensor(2), torch.tensor(3)))expected = op(img, (2, 3))- assert_allclose(actual, expected, rtol=1e-4, atol=1e-4)+ assert_close(actual, expected, rtol=1e-4, atol=1e-4)class TestCropByBoxes:@@ -235,7 +235,7 @@ class TestCropByBoxes:expected = torch.tensor([[[[6.0, 7.0], [10.0, 11.0]]]], device=device, dtype=dtype)patches = kornia.geometry.transform.crop.crop_by_boxes(inp, src, dst)- assert_allclose(patches, expected)+ assert_close(patches, expected)def test_crop_by_boxes_resizing(self, device, dtype):inp = torch.tensor(@@ -251,7 +251,7 @@ class TestCropByBoxes:expected = torch.tensor([[[[6.0, 6.5, 7.0], [10.0, 10.5, 11.0]]]], device=device, dtype=dtype)patches = kornia.geometry.transform.crop.crop_by_boxes(inp, src, dst)- assert_allclose(patches, expected, rtol=1e-4, atol=1e-4)+ assert_close(patches, expected, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device, dtype):inp = torch.randn((1, 1, 3, 3), device=device, dtype=dtype)@@ -278,7 +278,7 @@ class TestCropByTransform:expected = torch.tensor([[[[6.0, 7.0], [10.0, 11.0]]]], device=device, dtype=dtype)patches = kornia.geometry.transform.crop.crop_by_transform_mat(inp, transform, (2, 2))- assert_allclose(patches, expected)+ assert_close(patches, expected)def test_crop_by_boxes_resizing(self, device, dtype):inp = torch.tensor(@@ -294,7 +294,7 @@ class TestCropByTransform:expected = torch.tensor([[[[6.0, 6.5, 7.0], [10.0, 10.5, 11.0]]]], device=device, dtype=dtype)patches = kornia.geometry.transform.crop.crop_by_transform_mat(inp, transform, (2, 3))- assert_allclose(patches, expected, rtol=1e-4, atol=1e-4)+ assert_close(patches, expected, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device, dtype):inp = torch.randn((1, 1, 3, 3), device=device, dtype=dtype)diff --git a/test/geometry/transform/crop/test_crop3d.py b/test/geometry/transform/crop/test_crop3d.pyindex 933f5d622..3c9200203 100644--- a/test/geometry/transform/crop/test_crop3d.py+++ b/test/geometry/transform/crop/test_crop3d.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestBoundingBoxInferring3D:@@ -19,9 +19,9 @@ class TestBoundingBoxInferring3D:) # 2x8x3d, h, w = kornia.geometry.transform.crop.infer_box_shape3d(boxes)- assert_allclose(d, torch.tensor([31.0, 61.0], device=device, dtype=dtype))- assert_allclose(h, torch.tensor([21.0, 51.0], device=device, dtype=dtype))- assert_allclose(w, torch.tensor([11.0, 41.0], device=device, dtype=dtype))+ assert_close(d, torch.tensor([31.0, 61.0], device=device, dtype=dtype))+ assert_close(h, torch.tensor([21.0, 51.0], device=device, dtype=dtype))+ assert_close(w, torch.tensor([11.0, 41.0], device=device, dtype=dtype))def test_gradcheck(self, device, dtype):boxes = torch.tensor(@@ -45,7 +45,7 @@ class TestBoundingBoxInferring3D:actual = op_script(boxes)expected = op(boxes)- assert_allclose(actual, expected)+ assert_close(actual, expected)class TestCropAndResize3D:@@ -66,7 +66,7 @@ class TestCropAndResize3D:) # 1x8x3patches = kornia.crop_and_resize3d(inp, boxes, (depth, height, width))- assert_allclose(patches, expected)+ assert_close(patches, expected)def test_crop_batch(self, device, dtype):inp = torch.cat(@@ -97,7 +97,7 @@ class TestCropAndResize3D:) # 2x8x3patches = kornia.crop_and_resize3d(inp, boxes, (depth, height, width), align_corners=True)- assert_allclose(patches, expected)+ assert_close(patches, expected)def test_gradcheck(self, device, dtype):img = torch.arange(0.0, 64.0, device=device, dtype=dtype).view(1, 1, 4, 4, 4)@@ -127,7 +127,7 @@ class TestCropAndResize3D:actual = op_script(img, boxes, (4, 3, 2))expected = op(img, boxes, (4, 3, 2))- assert_allclose(actual, expected)+ assert_close(actual, expected)class TestCenterCrop3D:@@ -142,7 +142,7 @@ class TestCenterCrop3D:(inp.size(4) // 2 - crop_size[2] // 2) : (inp.size(4) // 2 + crop_size[2] // 2 + 1),]out_crop = kornia.center_crop3d(inp, crop_size, align_corners=True)- assert_allclose(out_crop, expected, rtol=1e-4, atol=1e-4)+ assert_close(out_crop, expected, rtol=1e-4, atol=1e-4)@pytest.mark.parametrize("crop_size", [(3, 5, 7), (5, 3, 7), (7, 3, 5)])def test_center_crop_357_batch(self, crop_size, device, dtype):@@ -160,7 +160,7 @@ class TestCenterCrop3D:(inp.size(4) // 2 - crop_size[2] // 2) : (inp.size(4) // 2 + crop_size[2] // 2 + 1),]out_crop = kornia.center_crop3d(inp, crop_size, align_corners=True)- assert_allclose(out_crop, expected, rtol=1e-4, atol=1e-4)+ assert_close(out_crop, expected, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device, dtype):img = torch.arange(0.0, 343.0, device=device, dtype=dtype).view(1, 1, 7, 7, 7)@@ -176,7 +176,7 @@ class TestCenterCrop3D:actual = op_script(img, (4, 3, 2))expected = kornia.center_crop3d(img, (4, 3, 2))- assert_allclose(actual, expected, rtol=1e-4, atol=1e-4)+ assert_close(actual, expected, rtol=1e-4, atol=1e-4)class TestCropByBoxes3D:@@ -218,7 +218,7 @@ class TestCropByBoxes3D:expected = inp[:, :, 1:3, 1:4, 1:4]patches = kornia.geometry.transform.crop.crop_by_boxes3d(inp, src_box, dst_box, align_corners=True)- assert_allclose(patches, expected, rtol=1e-4, atol=1e-4)+ assert_close(patches, expected, rtol=1e-4, atol=1e-4)def test_crop_by_boxes_resizing(self, device, dtype):inp = torch.arange(0.0, 343.0, device=device, dtype=dtype).view(1, 1, 7, 7, 7)@@ -262,7 +262,7 @@ class TestCropByBoxes3D:)patches = kornia.geometry.transform.crop.crop_by_boxes3d(inp, src_box, dst_box, align_corners=True)- assert_allclose(patches, expected, rtol=1e-4, atol=1e-4)+ assert_close(patches, expected, rtol=1e-4, atol=1e-4)def test_jit(self, device, dtype):# Define script@@ -305,7 +305,7 @@ class TestCropByBoxes3D:actual = op_script(inp, src_box, dst_box, align_corners=True)expected = op(inp, src_box, dst_box, align_corners=True)- assert_allclose(actual, expected, rtol=1e-4, atol=1e-4)+ assert_close(actual, expected, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device, dtype):inp = torch.randn((1, 1, 7, 7, 7), device=device, dtype=dtype)diff --git a/test/geometry/transform/test_affine.py b/test/geometry/transform/test_affine.pyindex 7ce73eff0..87cb0307a 100644--- a/test/geometry/transform/test_affine.py+++ b/test/geometry/transform/test_affine.py@@ -1,32 +1,32 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestResize:def test_smoke(self, device, dtype):inp = torch.rand(1, 3, 3, 4, device=device, dtype=dtype)out = kornia.resize(inp, (3, 4))- assert_allclose(inp, out, atol=1e-4, rtol=1e-4)+ assert_close(inp, out, atol=1e-4, rtol=1e-4)# 2Dinp = torch.rand(3, 4, device=device, dtype=dtype)out = kornia.resize(inp, (3, 4))- assert_allclose(inp, out, atol=1e-4, rtol=1e-4)+ assert_close(inp, out, atol=1e-4, rtol=1e-4)# 3Dinp = torch.rand(3, 3, 4, device=device, dtype=dtype)out = kornia.resize(inp, (3, 4))- assert_allclose(inp, out, atol=1e-4, rtol=1e-4)+ assert_close(inp, out, atol=1e-4, rtol=1e-4)# arbitrary diminp = torch.rand(1, 2, 3, 2, 1, 3, 3, 4, device=device, dtype=dtype)out = kornia.resize(inp, (3, 4))- assert_allclose(inp, out, atol=1e-4, rtol=1e-4)+ assert_close(inp, out, atol=1e-4, rtol=1e-4)def test_upsize(self, device, dtype):inp = torch.rand(1, 3, 3, 4, device=device, dtype=dtype)@@ -180,7 +180,7 @@ class TestRescale:def test_smoke(self, device, dtype):input = torch.rand(1, 3, 3, 4, device=device, dtype=dtype)output = kornia.rescale(input, (1.0, 1.0))- assert_allclose(input, output, atol=1e-4, rtol=1e-4)+ assert_close(input, output, atol=1e-4, rtol=1e-4)def test_upsize(self, device, dtype):input = torch.rand(1, 3, 3, 4, device=device, dtype=dtype)@@ -212,7 +212,7 @@ class TestRescale:device=device,dtype=dtype,)- assert_allclose(out, expected, atol=1e-3, rtol=1e-3)+ assert_close(out, expected, atol=1e-3, rtol=1e-3)def test_downscale_values_AA(self, device, dtype):inp_x = torch.arange(20, device=device, dtype=dtype) / 20.0@@ -234,7 +234,7 @@ class TestRescale:device=device,dtype=dtype,)- assert_allclose(out, expected, atol=1e-3, rtol=1e-3)+ assert_close(out, expected, atol=1e-3, rtol=1e-3)def test_one_param(self, device, dtype):input = torch.rand(1, 3, 3, 4, device=device, dtype=dtype)@@ -255,7 +255,7 @@ class TestRotate:# prepare transformationangle = torch.tensor([90.0], device=device, dtype=dtype)transform = kornia.Rotate(angle, align_corners=True)- assert_allclose(transform(inp), expected, atol=1e-4, rtol=1e-4)+ assert_close(transform(inp), expected, atol=1e-4, rtol=1e-4)def test_angle90_batch2(self, device, dtype):# prepare input data@@ -270,7 +270,7 @@ class TestRotate:# prepare transformationangle = torch.tensor([90.0, -90.0], device=device, dtype=dtype)transform = kornia.Rotate(angle, align_corners=True)- assert_allclose(transform(inp), expected, atol=1e-4, rtol=1e-4)+ assert_close(transform(inp), expected, atol=1e-4, rtol=1e-4)def test_angle90_batch2_broadcast(self, device, dtype):# prepare input data@@ -285,7 +285,7 @@ class TestRotate:# prepare transformationangle = torch.tensor([90.0], device=device, dtype=dtype)transform = kornia.Rotate(angle, align_corners=True)- assert_allclose(transform(inp), expected, atol=1e-4, rtol=1e-4)+ assert_close(transform(inp), expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):# test parameters@@ -305,7 +305,7 @@ class TestRotate:img = torch.ones(batch_size, channels, height, width, device=device, dtype=dtype)rot = kornia.Rotate(angle)rot_traced = torch.jit.trace(kornia.Rotate(angle), img)- assert_allclose(rot(img), rot_traced(img))+ assert_close(rot(img), rot_traced(img))class TestTranslate:@@ -316,7 +316,7 @@ class TestTranslate:# prepare transformationtranslation = torch.tensor([[1.0, 0.0]], device=device, dtype=dtype)transform = kornia.Translate(translation, align_corners=True)- assert_allclose(transform(inp), expected, atol=1e-4, rtol=1e-4)+ assert_close(transform(inp), expected, atol=1e-4, rtol=1e-4)def test_dxdy_batch(self, device, dtype):# prepare input data@@ -331,7 +331,7 @@ class TestTranslate:# prepare transformationtranslation = torch.tensor([[1.0, 0.0], [1.0, 1.0]], device=device, dtype=dtype)transform = kornia.Translate(translation, align_corners=True)- assert_allclose(transform(inp), expected, atol=1e-4, rtol=1e-4)+ assert_close(transform(inp), expected, atol=1e-4, rtol=1e-4)def test_dxdy_batch_broadcast(self, device, dtype):# prepare input data@@ -346,7 +346,7 @@ class TestTranslate:# prepare transformationtranslation = torch.tensor([[1.0, 0.0]], device=device, dtype=dtype)transform = kornia.Translate(translation, align_corners=True)- assert_allclose(transform(inp), expected, atol=1e-4, rtol=1e-4)+ assert_close(transform(inp), expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):# test parameters@@ -366,7 +366,7 @@ class TestTranslate:img = torch.ones(batch_size, channels, height, width, device=device, dtype=dtype)trans = kornia.Translate(translation)trans_traced = torch.jit.trace(kornia.Translate(translation), img)- assert_allclose(trans(img), trans_traced(img), atol=1e-4, rtol=1e-4)+ assert_close(trans(img), trans_traced(img), atol=1e-4, rtol=1e-4)class TestScale:@@ -380,7 +380,7 @@ class TestScale:# prepare transformationscale_factor = torch.tensor([[2.0, 2.0]], device=device, dtype=dtype)transform = kornia.Scale(scale_factor)- assert_allclose(transform(inp).sum().item(), 12.25, atol=1e-4, rtol=1e-4)+ assert_close(transform(inp).sum().item(), 12.25, atol=1e-4, rtol=1e-4)def test_scale_factor_05(self, device, dtype):# prepare input data@@ -397,7 +397,7 @@ class TestScale:# prepare transformationscale_factor = torch.tensor([[0.5, 0.5]], device=device, dtype=dtype)transform = kornia.Scale(scale_factor)- assert_allclose(transform(inp), expected, atol=1e-4, rtol=1e-4)+ assert_close(transform(inp), expected, atol=1e-4, rtol=1e-4)def test_scale_factor_05_batch2(self, device, dtype):# prepare input data@@ -414,7 +414,7 @@ class TestScale:# prepare transformationscale_factor = torch.tensor([[0.5, 0.5]], device=device, dtype=dtype)transform = kornia.Scale(scale_factor)- assert_allclose(transform(inp), expected, atol=1e-4, rtol=1e-4)+ assert_close(transform(inp), expected, atol=1e-4, rtol=1e-4)def test_scale_factor_05_batch2_broadcast(self, device, dtype):# prepare input data@@ -431,7 +431,7 @@ class TestScale:# prepare transformationscale_factor = torch.tensor([[0.5, 0.5]], device=device, dtype=dtype)transform = kornia.Scale(scale_factor)- assert_allclose(transform(inp), expected, atol=1e-4, rtol=1e-4)+ assert_close(transform(inp), expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):# test parameters@@ -451,7 +451,7 @@ class TestScale:img = torch.ones(batch_size, channels, height, width, device=device, dtype=dtype)trans = kornia.Scale(scale_factor)trans_traced = torch.jit.trace(kornia.Scale(scale_factor), img)- assert_allclose(trans(img), trans_traced(img), atol=1e-4, rtol=1e-4)+ assert_close(trans(img), trans_traced(img), atol=1e-4, rtol=1e-4)class TestShear:@@ -471,7 +471,7 @@ class TestShear:# prepare transformationshear = torch.tensor([[0.5, 0.0]], device=device, dtype=dtype)transform = kornia.Shear(shear)- assert_allclose(transform(inp), expected, atol=1e-4, rtol=1e-4)+ assert_close(transform(inp), expected, atol=1e-4, rtol=1e-4)def test_shear_y(self, device, dtype):# prepare input data@@ -489,7 +489,7 @@ class TestShear:# prepare transformationshear = torch.tensor([[0.0, 0.5]], device=device, dtype=dtype)transform = kornia.Shear(shear)- assert_allclose(transform(inp), expected, atol=1e-4, rtol=1e-4)+ assert_close(transform(inp), expected, atol=1e-4, rtol=1e-4)def test_shear_batch2(self, device, dtype):# prepare input data@@ -511,7 +511,7 @@ class TestShear:# prepare transformationshear = torch.tensor([[0.5, 0.0], [0.0, 0.5]], device=device, dtype=dtype)transform = kornia.Shear(shear)- assert_allclose(transform(inp), expected, atol=1e-4, rtol=1e-4)+ assert_close(transform(inp), expected, atol=1e-4, rtol=1e-4)def test_shear_batch2_broadcast(self, device, dtype):# prepare input data@@ -530,7 +530,7 @@ class TestShear:# prepare transformationshear = torch.tensor([[0.5, 0.0]], device=device, dtype=dtype)transform = kornia.Shear(shear)- assert_allclose(transform(inp), expected, atol=1e-4, rtol=1e-4)+ assert_close(transform(inp), expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):# test parameters@@ -550,7 +550,7 @@ class TestShear:img = torch.ones(batch_size, channels, height, width, device=device, dtype=dtype)trans = kornia.Shear(shear)trans_traced = torch.jit.trace(kornia.Shear(shear), img)- assert_allclose(trans(img), trans_traced(img), atol=1e-4, rtol=1e-4)+ assert_close(trans(img), trans_traced(img), atol=1e-4, rtol=1e-4)class TestAffine2d:@@ -575,7 +575,7 @@ class TestAffine2d:transform = kornia.Affine(angle=angle).to(device=device, dtype=dtype)actual = transform(input)expected = kornia.rotate(input, angle)- assert_allclose(actual, expected, atol=1e-4, rtol=1e-4)+ assert_close(actual, expected, atol=1e-4, rtol=1e-4)def test_affine_translate(self, device, dtype):# TODO: Remove when #666 is implemented@@ -588,7 +588,7 @@ class TestAffine2d:transform = kornia.Affine(translation=translation).to(device=device, dtype=dtype)actual = transform(input)expected = kornia.translate(input, translation)- assert_allclose(actual, expected, atol=1e-4, rtol=1e-4)+ assert_close(actual, expected, atol=1e-4, rtol=1e-4)def test_affine_scale(self, device, dtype):# TODO: Remove when #666 is implemented@@ -602,7 +602,7 @@ class TestAffine2d:transform = kornia.Affine(scale_factor=scale_factor).to(device=device, dtype=dtype)actual = transform(input)expected = kornia.scale(input, scale_factor)- assert_allclose(actual, expected, atol=1e-4, rtol=1e-4)+ assert_close(actual, expected, atol=1e-4, rtol=1e-4)@pytest.mark.skip("_compute_shear_matrix and get_affine_matrix2d yield different results. "@@ -616,7 +616,7 @@ class TestAffine2d:transform = kornia.Affine(shear=shear, device=device, dtype=dtype)actual = transform(input)expected = kornia.shear(input, shear)- assert_allclose(actual, expected, atol=1e-4, rtol=1e-4)+ assert_close(actual, expected, atol=1e-4, rtol=1e-4)def test_affine_rotate_translate(self, device, dtype):# TODO: Remove when #666 is implemented@@ -643,7 +643,7 @@ class TestAffine2d:device=device, dtype=dtype)actual = transform(input)- assert_allclose(actual, expected, atol=1e-4, rtol=1e-4)+ assert_close(actual, expected, atol=1e-4, rtol=1e-4)def test_compose_affine_matrix_3x3(self, device, dtype):"""To get parameters:@@ -693,4 +693,4 @@ class TestAffine2d:T([math.radians(shear[1])]).view(-1, 1),)matrix_kornia = matrix_kornia.inverse()[0, :2].detach().cpu()- assert_allclose(matrix_kornia, matrix_expected, atol=1e-4, rtol=1e-4)+ assert_close(matrix_kornia, matrix_expected, atol=1e-4, rtol=1e-4)diff --git a/test/geometry/transform/test_elastic_transform.py b/test/geometry/transform/test_elastic_transform.pyindex c84cec967..73714cef5 100644--- a/test/geometry/transform/test_elastic_transform.py+++ b/test/geometry/transform/test_elastic_transform.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniafrom kornia.geometry.transform import elastic_transform2d+from kornia.testing import assert_closeclass TestElasticTransform:@@ -70,7 +70,7 @@ class TestElasticTransform:)actual = elastic_transform2d(image, noise)- assert_allclose(actual, expected, atol=1e-3, rtol=1e-3)+ assert_close(actual, expected, atol=1e-3, rtol=1e-3)@pytest.mark.parametrize("requires_grad", [True, False])def test_gradcheck(self, device, dtype, requires_grad):@@ -85,4 +85,4 @@ class TestElasticTransform:op = kornia.geometry.transform.elastic_transform2dop_jit = torch.jit.script(op)- assert_allclose(op(image, noise), op_jit(image, noise))+ assert_close(op(image, noise), op_jit(image, noise))diff --git a/test/geometry/transform/test_flip.py b/test/geometry/transform/test_flip.pyindex 1f8d96d4d..236293c9d 100644--- a/test/geometry/transform/test_flip.py+++ b/test/geometry/transform/test_flip.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestVflip:@@ -64,7 +64,7 @@ class TestVflip:actual = op_trace(input)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_gradcheck(self, device, dtype):@@ -134,7 +134,7 @@ class TestHflip:actual = op_trace(input)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_gradcheck(self, device, dtype):@@ -202,7 +202,7 @@ class TestRot180:actual = op_trace(input)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_gradcheck(self, device, dtype):diff --git a/test/geometry/transform/test_homography_warper.py b/test/geometry/transform/test_homography_warper.pyindex ff24958da..04d70ca95 100644--- a/test/geometry/transform/test_homography_warper.py+++ b/test/geometry/transform/test_homography_warper.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closefrom kornia.utils.helpers import _torch_inverse_cast@@ -23,7 +23,7 @@ class TestHomographyWarper:# warp from source to destinationpatch_dst = warper(patch_src, dst_homo_src)- assert_allclose(patch_src, patch_dst)+ assert_close(patch_src, patch_dst)@pytest.mark.parametrize("batch_size", [1, 3])def test_normalize_homography_identity(self, batch_size, device, dtype):@@ -42,7 +42,7 @@ class TestHomographyWarper:res = torch.tensor([[[4.0, 0.0, 3.0], [0.0, 1 / 3, -2 / 3], [0.0, 0.0, 1.0]]], device=device, dtype=dtype).repeat(batch_size, 1, 1)- assert_allclose(norm_homo, res, atol=1e-4, rtol=1e-4)+ assert_close(norm_homo, res, atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("batch_size", [1, 3])def test_denormalize_homography_identity(self, batch_size, device, dtype):@@ -61,7 +61,7 @@ class TestHomographyWarper:res = torch.tensor([[[0.25, 0.0, 0.0], [0.0, 3.0, 0], [0.0, 0.0, 1.0]]], device=device, dtype=dtype).repeat(batch_size, 1, 1)- assert_allclose(denorm_homo, res, atol=1e-4, rtol=1e-4)+ assert_close(denorm_homo, res, atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("batch_size", [1, 3])def test_normalize_homography_general(self, batch_size, device, dtype):@@ -123,8 +123,8 @@ class TestHomographyWarper:# the grid the src plus the offset should be equal to the flow# on the x-axis, y-axis remains the same.- assert_allclose(grid[..., 0].to(device=device, dtype=dtype) + offset, flow[..., 0])- assert_allclose(grid[..., 1].to(device=device, dtype=dtype), flow[..., 1])+ assert_close(grid[..., 0].to(device=device, dtype=dtype) + offset, flow[..., 0])+ assert_close(grid[..., 1].to(device=device, dtype=dtype), flow[..., 1])@pytest.mark.parametrize("batch_shape", [(1, 1, 4, 5), (2, 2, 4, 6), (3, 1, 5, 7)])def test_identity_resize(self, batch_shape, device, dtype):@@ -138,10 +138,10 @@ class TestHomographyWarper:patch_dst = warper(patch_src, dst_homo_src)# check the corners- assert_allclose(patch_src[..., 0, 0], patch_dst[..., 0, 0], atol=1e-4, rtol=1e-4)- assert_allclose(patch_src[..., 0, -1], patch_dst[..., 0, -1], atol=1e-4, rtol=1e-4)- assert_allclose(patch_src[..., -1, 0], patch_dst[..., -1, 0], atol=1e-4, rtol=1e-4)- assert_allclose(patch_src[..., -1, -1], patch_dst[..., -1, -1], atol=1e-4, rtol=1e-4)+ assert_close(patch_src[..., 0, 0], patch_dst[..., 0, 0], atol=1e-4, rtol=1e-4)+ assert_close(patch_src[..., 0, -1], patch_dst[..., 0, -1], atol=1e-4, rtol=1e-4)+ assert_close(patch_src[..., -1, 0], patch_dst[..., -1, 0], atol=1e-4, rtol=1e-4)+ assert_close(patch_src[..., -1, -1], patch_dst[..., -1, -1], atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("shape", [(4, 5), (2, 6), (4, 3), (5, 7)])def test_translation(self, shape, device, dtype):@@ -155,7 +155,7 @@ class TestHomographyWarper:# instantiate warper and from source to destinationwarper = kornia.HomographyWarper(height, width, align_corners=True)patch_dst = warper(patch_src, dst_homo_src)- assert_allclose(patch_src[..., 1:], patch_dst[..., :-1], atol=1e-4, rtol=1e-4)+ assert_close(patch_src[..., 1:], patch_dst[..., :-1], atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("batch_shape", [(1, 1, 3, 5), (2, 2, 4, 3), (3, 1, 2, 3)])def test_rotation(self, batch_shape, device, dtype):@@ -175,10 +175,10 @@ class TestHomographyWarper:patch_dst = warper(patch_src, dst_homo_src)# check the corners- assert_allclose(patch_src[..., 0, 0], patch_dst[..., 0, -1], atol=1e-4, rtol=1e-4)- assert_allclose(patch_src[..., 0, -1], patch_dst[..., -1, -1], atol=1e-4, rtol=1e-4)- assert_allclose(patch_src[..., -1, 0], patch_dst[..., 0, 0], atol=1e-4, rtol=1e-4)- assert_allclose(patch_src[..., -1, -1], patch_dst[..., -1, 0], atol=1e-4, rtol=1e-4)+ assert_close(patch_src[..., 0, 0], patch_dst[..., 0, -1], atol=1e-4, rtol=1e-4)+ assert_close(patch_src[..., 0, -1], patch_dst[..., -1, -1], atol=1e-4, rtol=1e-4)+ assert_close(patch_src[..., -1, 0], patch_dst[..., 0, 0], atol=1e-4, rtol=1e-4)+ assert_close(patch_src[..., -1, -1], patch_dst[..., -1, 0], atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("batch_size", [1, 2, 3])def test_homography_warper(self, batch_size, device, dtype):@@ -219,7 +219,7 @@ class TestHomographyWarper:patch_dst, _torch_inverse_cast(dst_homo_src_i), (height, width), align_corners=True)- assert_allclose(patch_dst_to_src, patch_dst_to_src_functional, atol=1e-4, rtol=1e-4)+ assert_close(patch_dst_to_src, patch_dst_to_src_functional, atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("batch_shape", [(1, 1, 7, 5), (2, 3, 8, 5), (1, 1, 7, 16)])def test_gradcheck(self, batch_shape, device, dtype):@@ -276,7 +276,7 @@ class TestHomographyWarper:normalized_coordinates=normalized_coordinates,)- assert_allclose(patch_dst, patch_dst_jit, atol=1e-4, rtol=1e-4)+ assert_close(patch_dst, patch_dst_jit, atol=1e-4, rtol=1e-4)class TestHomographyNormalTransform:@@ -296,7 +296,7 @@ class TestHomographyNormalTransform:def test_transform2d(self, height, width, expected, device, dtype):output = kornia.normal_transform_pixel(height, width, device=device, dtype=dtype)- assert_allclose(output, expected.to(device=device, dtype=dtype), atol=1e-4, rtol=1e-4)+ assert_close(output, expected.to(device=device, dtype=dtype), atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("height", [1, 2, 5])@pytest.mark.parametrize("width", [1, 2, 5])@@ -310,12 +310,12 @@ class TestHomographyNormalTransform:expected = torch.tensor([[-1.0, -1.0], [1.0, 1.0]], device=device, dtype=dtype)transform = kornia.normal_transform_pixel(height, width, device=device, dtype=dtype)output = kornia.transform_points(transform, input)- assert_allclose(output, expected.to(device=device, dtype=dtype), atol=1e-4, rtol=1e-4)+ assert_close(output, expected.to(device=device, dtype=dtype), atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("height,width,depth,expected", [(2, 6, 4, expected_3d_0), (1, 6, 4, expected_3d_1)])def test_transform3d(self, height, width, depth, expected, device, dtype):output = kornia.normal_transform_pixel3d(depth, height, width, device=device, dtype=dtype)- assert_allclose(output, expected.to(device=device, dtype=dtype), atol=1e-4, rtol=1e-4)+ assert_close(output, expected.to(device=device, dtype=dtype), atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("height", [1, 2, 5])@pytest.mark.parametrize("width", [1, 2, 5])@@ -330,7 +330,7 @@ class TestHomographyNormalTransform:expected = torch.tensor([[-1.0, -1.0, -1.0], [1.0, 1.0, 1.0]], device=device, dtype=dtype)transform = kornia.normal_transform_pixel3d(depth, height, width, device=device, dtype=dtype)output = kornia.transform_points(transform, input)- assert_allclose(output, expected.to(device=device, dtype=dtype), atol=1e-4, rtol=1e-4)+ assert_close(output, expected.to(device=device, dtype=dtype), atol=1e-4, rtol=1e-4)class TestHomographyWarper3D:@@ -351,13 +351,13 @@ class TestHomographyWarper3D:norm = kornia.normal_transform_pixel3d(input_shape[0], input_shape[1], input_shape[2]).to(device=device, dtype=dtype)- assert_allclose(norm, res, rtol=1e-4, atol=1e-4)+ assert_close(norm, res, rtol=1e-4, atol=1e-4)norm_homo = kornia.normalize_homography3d(dst_homo_src, input_shape, input_shape).to(device=device, dtype=dtype)- assert_allclose(norm_homo, dst_homo_src, rtol=1e-4, atol=1e-4)+ assert_close(norm_homo, dst_homo_src, rtol=1e-4, atol=1e-4)norm_homo = kornia.normalize_homography3d(dst_homo_src, input_shape, input_shape).to(device=device, dtype=dtype)- assert_allclose(norm_homo, dst_homo_src, rtol=1e-4, atol=1e-4)+ assert_close(norm_homo, dst_homo_src, rtol=1e-4, atol=1e-4)# change output scalenorm_homo = kornia.normalize_homography3d(@@ -368,7 +368,7 @@ class TestHomographyWarper3D:device=device,dtype=dtype,).repeat(batch_size, 1, 1)- assert_allclose(norm_homo, res, rtol=1e-4, atol=1e-4)+ assert_close(norm_homo, res, rtol=1e-4, atol=1e-4)@pytest.mark.parametrize("batch_size", [1, 3])def test_normalize_homography_general(self, batch_size, device, dtype):@@ -402,6 +402,6 @@ class TestHomographyWarper3D:# the grid the src plus the offset should be equal to the flow# on the x-axis, y-axis remains the same.- assert_allclose(grid[..., 0].to(device=device, dtype=dtype) + offset, flow[..., 0], atol=1e-4, rtol=1e-4)- assert_allclose(grid[..., 1].to(device=device, dtype=dtype), flow[..., 1], atol=1e-4, rtol=1e-4)- assert_allclose(grid[..., 2].to(device=device, dtype=dtype), flow[..., 2], atol=1e-4, rtol=1e-4)+ assert_close(grid[..., 0].to(device=device, dtype=dtype) + offset, flow[..., 0], atol=1e-4, rtol=1e-4)+ assert_close(grid[..., 1].to(device=device, dtype=dtype), flow[..., 1], atol=1e-4, rtol=1e-4)+ assert_close(grid[..., 2].to(device=device, dtype=dtype), flow[..., 2], atol=1e-4, rtol=1e-4)diff --git a/test/geometry/transform/test_imgwarp.py b/test/geometry/transform/test_imgwarp.pyindex 3051ea86b..933db4fce 100644--- a/test/geometry/transform/test_imgwarp.py+++ b/test/geometry/transform/test_imgwarp.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_close@pytest.mark.parametrize("batch_size", [1, 2, 5])@@ -25,7 +25,7 @@ def test_get_perspective_transform(batch_size, device, dtype):# compute transform from source to targetdst_homo_src = kornia.get_perspective_transform(points_src, points_dst)- assert_allclose(kornia.transform_points(dst_homo_src, points_src), points_dst, rtol=1e-4, atol=1e-4)+ assert_close(kornia.transform_points(dst_homo_src, points_src), points_dst, rtol=1e-4, atol=1e-4)# compute gradient checkpoints_src = utils.tensor_to_gradcheck_var(points_src) # to var@@ -47,10 +47,10 @@ def test_rotation_matrix2d(batch_size, device, dtype):M = kornia.get_rotation_matrix2d(center, angle, scale)for i in range(batch_size):- assert_allclose(M[i, 0, 0].item(), 0.0, rtol=1e-4, atol=1e-4)- assert_allclose(M[i, 0, 1].item(), 1.0, rtol=1e-4, atol=1e-4)- assert_allclose(M[i, 1, 0].item(), -1.0, rtol=1e-4, atol=1e-4)- assert_allclose(M[i, 1, 1].item(), 0.0, rtol=1e-4, atol=1e-4)+ assert_close(M[i, 0, 0].item(), 0.0, rtol=1e-4, atol=1e-4)+ assert_close(M[i, 0, 1].item(), 1.0, rtol=1e-4, atol=1e-4)+ assert_close(M[i, 1, 0].item(), -1.0, rtol=1e-4, atol=1e-4)+ assert_close(M[i, 1, 1].item(), 0.0, rtol=1e-4, atol=1e-4)# 90 deg rotation + 2x scalecenter = center_base@@ -59,10 +59,10 @@ def test_rotation_matrix2d(batch_size, device, dtype):M = kornia.get_rotation_matrix2d(center, angle, scale)for i in range(batch_size):- assert_allclose(M[i, 0, 0].item(), 0.0, rtol=1e-4, atol=1e-4)- assert_allclose(M[i, 0, 1].item(), 2.0, rtol=1e-4, atol=1e-4)- assert_allclose(M[i, 1, 0].item(), -2.0, rtol=1e-4, atol=1e-4)- assert_allclose(M[i, 1, 1].item(), 0.0, rtol=1e-4, atol=1e-4)+ assert_close(M[i, 0, 0].item(), 0.0, rtol=1e-4, atol=1e-4)+ assert_close(M[i, 0, 1].item(), 2.0, rtol=1e-4, atol=1e-4)+ assert_close(M[i, 1, 0].item(), -2.0, rtol=1e-4, atol=1e-4)+ assert_close(M[i, 1, 1].item(), 0.0, rtol=1e-4, atol=1e-4)# 45 deg rotationcenter = center_base@@ -71,10 +71,10 @@ def test_rotation_matrix2d(batch_size, device, dtype):M = kornia.get_rotation_matrix2d(center, angle, scale)for i in range(batch_size):- assert_allclose(M[i, 0, 0].item(), 0.7071)- assert_allclose(M[i, 0, 1].item(), 0.7071)- assert_allclose(M[i, 1, 0].item(), -0.7071)- assert_allclose(M[i, 1, 1].item(), 0.7071)+ assert_close(M[i, 0, 0].item(), 0.7071)+ assert_close(M[i, 0, 1].item(), 0.7071)+ assert_close(M[i, 1, 0].item(), -0.7071)+ assert_close(M[i, 1, 1].item(), 0.7071)# evaluate function gradientcenter = utils.tensor_to_gradcheck_var(center) # to var@@ -89,7 +89,7 @@ class TestWarpAffine:aff_ab = torch.eye(2, 3, device=device, dtype=dtype)[None] # 1x2x3img_b = torch.rand(batch_size, channels, height, width, device=device, dtype=dtype)img_a = kornia.warp_affine(img_b, aff_ab, (height, width))- assert_allclose(img_b, img_a)+ assert_close(img_b, img_a)@pytest.mark.parametrize("batch_shape", ([1, 3, 2, 5], [2, 4, 3, 4], [3, 5, 6, 2]))@pytest.mark.parametrize("out_shape", ([2, 5], [3, 4], [6, 2]))@@ -133,7 +133,7 @@ class TestWarpAffine:# Same as opencv: cv2.warpAffine(kornia.tensor_to_image(img_b), aff_ab[0].numpy(), (w, h))img_a = kornia.warp_affine(img_b, aff_ab, (h, w))- assert_allclose(img_a, expected)+ assert_close(img_a, expected)def test_rotation_inverse(self, device, dtype):h, w = 4, 4@@ -153,7 +153,7 @@ class TestWarpAffine:# invert the transformaff_ba = kornia.convert_affinematrix_to_homography(aff_ab).inverse()[..., :2, :]img_b_hat = kornia.warp_affine(img_a, aff_ba, (h, w))- assert_allclose(img_b_hat, img_b, atol=1e-3, rtol=1e-3)+ assert_close(img_b_hat, img_b, atol=1e-3, rtol=1e-3)def test_jit(self, device, dtype):aff_ab = torch.eye(2, 3, device=device, dtype=dtype)[None]@@ -161,7 +161,7 @@ class TestWarpAffine:args = (img, aff_ab, (4, 5))op = kornia.warp_affineop_jit = torch.jit.script(op)- assert_allclose(op(*args), op_jit(*args))+ assert_close(op(*args), op_jit(*args))def test_gradcheck(self, device, dtype):batch_size, channels, height, width = 1, 2, 3, 4@@ -178,7 +178,7 @@ class TestWarpPerspective:img_b = torch.rand(batch_size, channels, height, width, device=device, dtype=dtype)H_ab = kornia.eye_like(3, img_b)img_a = kornia.warp_perspective(img_b, H_ab, (height, width))- assert_allclose(img_b, img_a)+ assert_close(img_b, img_a)@pytest.mark.parametrize("batch_shape", ([1, 3, 2, 5], [2, 4, 3, 4], [3, 5, 6, 2]))@pytest.mark.parametrize("out_shape", ([2, 5], [3, 4], [6, 2]))@@ -222,7 +222,7 @@ class TestWarpPerspective:# Same as opencv: cv2.warpPerspective(kornia.tensor_to_image(img_b), homo_ab[0].numpy(), (w, h))img_a = kornia.warp_perspective(img_b, homo_ab, (h, w))- assert_allclose(img_a, expected, atol=1e-4, rtol=1e-4)+ assert_close(img_a, expected, atol=1e-4, rtol=1e-4)def test_rotation_inverse(self, device, dtype):h, w = 4, 4@@ -244,7 +244,7 @@ class TestWarpPerspective:# invert the transformH_ba = torch.inverse(H_ab)img_b_hat = kornia.warp_perspective(img_a, H_ba, (h, w))- assert_allclose(img_b_hat, img_b, rtol=1e-4, atol=1e-4)+ assert_close(img_b_hat, img_b, rtol=1e-4, atol=1e-4)@pytest.mark.parametrize("batch_size", [1, 5])@pytest.mark.parametrize("channels", [1, 5])@@ -277,7 +277,7 @@ class TestWarpPerspective:# warp and assertpatch_warped = kornia.warp_perspective(patch, dst_trans_src, (dst_h, dst_w))- assert_allclose(patch_warped, expected)+ assert_close(patch_warped, expected)def test_crop_center_resize(self, device, dtype):# generate input data@@ -318,7 +318,7 @@ class TestWarpPerspective:# warp and assertpatch_warped = kornia.warp_perspective(patch, dst_trans_src, (dst_h, dst_w))- assert_allclose(patch_warped, expected)+ assert_close(patch_warped, expected)def test_jit(self, device, dtype):img = torch.rand(1, 2, 3, 4, device=device, dtype=dtype)@@ -326,7 +326,7 @@ class TestWarpPerspective:args = (img, H_ab, (4, 5))op = kornia.warp_perspectiveop_jit = torch.jit.script(op)- assert_allclose(op(*args), op_jit(*args))+ assert_close(op(*args), op_jit(*args))def test_gradcheck(self, device, dtype):batch_size, channels, height, width = 1, 2, 3, 4@@ -344,7 +344,7 @@ class TestRemap:input = torch.ones(1, 1, height, width, device=device, dtype=dtype)grid = kornia.utils.create_meshgrid(height, width, normalized_coordinates=False, device=device).to(dtype)input_warped = kornia.remap(input, grid[..., 0], grid[..., 1], align_corners=True)- assert_allclose(input, input_warped, rtol=1e-4, atol=1e-4)+ assert_close(input, input_warped, rtol=1e-4, atol=1e-4)def test_shift(self, device, dtype):height, width = 3, 4@@ -359,7 +359,7 @@ class TestRemap:grid += 1.0 # apply shift in both x/y directioninput_warped = kornia.remap(inp, grid[..., 0], grid[..., 1], align_corners=True)- assert_allclose(input_warped, expected, rtol=1e-4, atol=1e-4)+ assert_close(input_warped, expected, rtol=1e-4, atol=1e-4)def test_shift_batch(self, device, dtype):height, width = 3, 4@@ -383,7 +383,7 @@ class TestRemap:grid[1, ..., 1] += 1.0 # apply shift in the y directioninput_warped = kornia.remap(inp, grid[..., 0], grid[..., 1], align_corners=True)- assert_allclose(input_warped, expected, rtol=1e-4, atol=1e-4)+ assert_close(input_warped, expected, rtol=1e-4, atol=1e-4)def test_shift_batch_broadcast(self, device, dtype):height, width = 3, 4@@ -398,7 +398,7 @@ class TestRemap:grid += 1.0 # apply shift in both x/y directioninput_warped = kornia.remap(inp, grid[..., 0], grid[..., 1], align_corners=True)- assert_allclose(input_warped, expected, rtol=1e-4, atol=1e-4)+ assert_close(input_warped, expected, rtol=1e-4, atol=1e-4)def test_normalized_coordinates(self, device, dtype):height, width = 3, 4@@ -418,7 +418,7 @@ class TestRemap:input_warped = kornia.remap(inp, grid[..., 0], grid[..., 1], align_corners=True, normalized_coordinates=normalized_coordinates)- assert_allclose(input_warped, expected, rtol=1e-4, atol=1e-4)+ assert_close(input_warped, expected, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device, dtype):batch_size, channels, height, width = 1, 2, 3, 4@@ -445,7 +445,7 @@ class TestRemap:input = (img, grid[..., 0], grid[..., 1])actual = op_script(*input)expected = kornia.remap(*input)- assert_allclose(actual, expected, rtol=1e-4, atol=1e-4)+ assert_close(actual, expected, rtol=1e-4, atol=1e-4)@pytest.mark.skip(reason="turn off all jit for a while")def test_jit_trace(self, device, dtype):@@ -471,14 +471,14 @@ class TestRemap:input_tuple = (img, grid[..., 0], grid[..., 1])actual = op_script(*input_tuple)expected = kornia.remap(*input_tuple)- assert_allclose(actual, expected, rtol=1e-4, atol=1e-4)+ assert_close(actual, expected, rtol=1e-4, atol=1e-4)class TestInvertAffineTransform:def test_smoke(self, device, dtype):matrix = torch.eye(2, 3, device=device, dtype=dtype)[None]matrix_inv = kornia.invert_affine_transform(matrix)- assert_allclose(matrix, matrix_inv, rtol=1e-4, atol=1e-4)+ assert_close(matrix, matrix_inv, rtol=1e-4, atol=1e-4)def test_rot90(self, device, dtype):angle = torch.tensor([90.0], device=device, dtype=dtype)@@ -487,7 +487,7 @@ class TestInvertAffineTransform:expected = torch.tensor([[[0.0, -1.0, 0.0], [1.0, 0.0, 0.0]]], device=device, dtype=dtype)matrix = kornia.get_rotation_matrix2d(center, angle, scale)matrix_inv = kornia.invert_affine_transform(matrix)- assert_allclose(matrix_inv, expected, rtol=1e-4, atol=1e-4)+ assert_close(matrix_inv, expected, rtol=1e-4, atol=1e-4)def test_rot90_batch(self, device, dtype):angle = torch.tensor([90.0], device=device, dtype=dtype)@@ -496,7 +496,7 @@ class TestInvertAffineTransform:expected = torch.tensor([[[0.0, -1.0, 0.0], [1.0, 0.0, 0.0]]], device=device, dtype=dtype).repeat(2, 1, 1)matrix = kornia.get_rotation_matrix2d(center, angle, scale).repeat(2, 1, 1)matrix_inv = kornia.invert_affine_transform(matrix)- assert_allclose(matrix_inv, expected, rtol=1e-4, atol=1e-4)+ assert_close(matrix_inv, expected, rtol=1e-4, atol=1e-4)def test_gradcheck(self, device, dtype):matrix = torch.eye(2, 3, device=device, dtype=dtype)[None]@@ -513,7 +513,7 @@ class TestInvertAffineTransform:op_traced = torch.jit.trace(op_script, matrix)actual = op_traced(matrix)expected = kornia.invert_affine_transform(matrix)- assert_allclose(actual, expected, rtol=1e-4, atol=1e-4)+ assert_close(actual, expected, rtol=1e-4, atol=1e-4)@pytest.mark.skip(reason="turn off all jit for a while")def test_jit_trace(self, device, dtype):@@ -526,4 +526,4 @@ class TestInvertAffineTransform:op_traced = torch.jit.trace(op_script, matrix)actual = op_traced(matrix_2)expected = kornia.invert_affine_transform(matrix_2)- assert_allclose(actual, expected, rtol=1e-4, atol=1e-4)+ assert_close(actual, expected, rtol=1e-4, atol=1e-4)diff --git a/test/geometry/transform/test_projwarp.py b/test/geometry/transform/test_projwarp.pyindex 5d609567d..2cec00c27 100644--- a/test/geometry/transform/test_projwarp.py+++ b/test/geometry/transform/test_projwarp.py@@ -1,11 +1,11 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.geometry.transform.projwarp as projimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestWarpAffine3d:@@ -38,7 +38,7 @@ class TestWarpAffine3d:P = kornia.geometry.convert_affinematrix_to_homography3d(P)P_hat = (P.inverse() @ P)[:, :3]output = proj.warp_affine3d(input, P_hat, out_shape, flags='nearest')- assert_allclose(output, input, rtol=1e-4, atol=1e-4)+ assert_close(output, input, rtol=1e-4, atol=1e-4)def test_rotate_x(self, device, dtype):input = torch.tensor(@@ -77,7 +77,7 @@ class TestWarpAffine3d:scales: torch.Tensor = torch.ones_like(angles, device=device, dtype=dtype)P = proj.get_projective_transform(center, angles, scales)output = proj.warp_affine3d(input, P, (3, 3, 3))- assert_allclose(output, expected, rtol=1e-4, atol=1e-4)+ assert_close(output, expected, rtol=1e-4, atol=1e-4)def test_rotate_y(self, device, dtype):input = torch.tensor(@@ -116,7 +116,7 @@ class TestWarpAffine3d:scales: torch.Tensor = torch.ones_like(angles, device=device, dtype=dtype)P = proj.get_projective_transform(center, angles, scales)output = proj.warp_affine3d(input, P, (3, 3, 3))- assert_allclose(output, expected, rtol=1e-4, atol=1e-4)+ assert_close(output, expected, rtol=1e-4, atol=1e-4)def test_rotate_z(self, device, dtype):input = torch.tensor(@@ -155,7 +155,7 @@ class TestWarpAffine3d:scales: torch.Tensor = torch.ones_like(angles, device=device, dtype=dtype)P = proj.get_projective_transform(center, angles, scales)output = proj.warp_affine3d(input, P, (3, 3, 3))- assert_allclose(output, expected, rtol=1e-4, atol=1e-4)+ assert_close(output, expected, rtol=1e-4, atol=1e-4)def test_rotate_y_large(self, device, dtype):"""Rotates 90deg anti-clockwise."""@@ -205,7 +205,7 @@ class TestWarpAffine3d:scales: torch.Tensor = torch.ones_like(angles, device=device, dtype=dtype)P = proj.get_projective_transform(center, angles, scales)output = proj.warp_affine3d(input, P, (3, 3, 3))- assert_allclose(output, expected, rtol=1e-4, atol=1e-4)+ assert_close(output, expected, rtol=1e-4, atol=1e-4)class TestGetRotationMatrix3d:@@ -233,7 +233,7 @@ class TestGetRotationMatrix3d:P_expected = torch.tensor([[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0]], device=device, dtype=dtype).unsqueeze(0)- assert_allclose(P, P_expected, atol=1e-4, rtol=1e-4)+ assert_close(P, P_expected, atol=1e-4, rtol=1e-4)def test_rot90x(self, device, dtype):center = torch.zeros(1, 3, device=device, dtype=dtype)@@ -243,7 +243,7 @@ class TestGetRotationMatrix3d:P_expected = torch.tensor([[1.0, 0.0, 0.0, 0.0], [0.0, 0.0, -1.0, 0.0], [0.0, 1.0, 0.0, 0.0]], device=device, dtype=dtype).unsqueeze(0)- assert_allclose(P, P_expected, atol=1e-4, rtol=1e-4)+ assert_close(P, P_expected, atol=1e-4, rtol=1e-4)def test_rot90y(self, device, dtype):center = torch.zeros(1, 3, device=device, dtype=dtype)@@ -253,7 +253,7 @@ class TestGetRotationMatrix3d:P_expected = torch.tensor([[0.0, 0.0, 1.0, 0.0], [0.0, 1.0, 0.0, 0.0], [-1.0, 0.0, 0.0, 0.0]], device=device, dtype=dtype).unsqueeze(0)- assert_allclose(P, P_expected, atol=1e-4, rtol=1e-4)+ assert_close(P, P_expected, atol=1e-4, rtol=1e-4)def test_rot90z(self, device, dtype):center = torch.zeros(1, 3, device=device, dtype=dtype)@@ -263,7 +263,7 @@ class TestGetRotationMatrix3d:P_expected = torch.tensor([[0.0, -1.0, 0.0, 0.0], [1.0, 0.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0]], device=device, dtype=dtype).unsqueeze(0)- assert_allclose(P, P_expected, atol=1e-4, rtol=1e-4)+ assert_close(P, P_expected, atol=1e-4, rtol=1e-4)def test_gradcheck(self, device, dtype):# generate input data@@ -292,7 +292,7 @@ class TestPerspectiveTransform3D:# TODO: get_perspective_transform3d seems to be correct since it would result in the# expected output for cropping volumes. Not sure what is going on here.- assert_allclose(kornia.transform_points(dst_homo_src, points_src), points_dst, rtol=1e-4, atol=1e-4)+ assert_close(kornia.transform_points(dst_homo_src, points_src), points_dst, rtol=1e-4, atol=1e-4)# compute gradient checkpoints_src = utils.tensor_to_gradcheck_var(points_src) # to var@@ -352,7 +352,7 @@ class TestPerspectiveTransform3D:dtype=dtype,)- assert_allclose(out, expected, rtol=1e-4, atol=1e-4)+ assert_close(out, expected, rtol=1e-4, atol=1e-4)# compute gradient checkpoints_src = utils.tensor_to_gradcheck_var(src) # to vardiff --git a/test/geometry/transform/test_pyramid.py b/test/geometry/transform/test_pyramid.pyindex 830c91429..2b6310335 100644--- a/test/geometry/transform/test_pyramid.py+++ b/test/geometry/transform/test_pyramid.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestPyrUp:@@ -27,7 +27,7 @@ class TestPyrUp:img = torch.rand(2, 3, 4, 5, device=device, dtype=dtype)op = kornia.geometry.pyrupop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))class TestPyrDown:@@ -45,8 +45,8 @@ class TestPyrDown:inp = torch.zeros(1, 1, 6, 6, device=device, dtype=dtype)inp[:, :, 2:4, 2:4] = 1.0pyr_out = kornia.geometry.PyrDown()(inp).squeeze()- assert_allclose(pyr_out, pyr_out.flip(0))- assert_allclose(pyr_out, pyr_out.flip(1))+ assert_close(pyr_out, pyr_out.flip(0))+ assert_close(pyr_out, pyr_out.flip(1))def test_gradcheck(self, device, dtype):img = torch.rand(1, 2, 5, 4, device=device, dtype=dtype)@@ -57,7 +57,7 @@ class TestPyrDown:img = torch.rand(2, 3, 4, 5, device=device, dtype=dtype)op = kornia.geometry.pyrdownop_jit = torch.jit.script(op)- assert_allclose(op(img), op_jit(img))+ assert_close(op(img), op_jit(img))class TestScalePyramid:@@ -108,8 +108,8 @@ class TestScalePyramid:for i, pyr_level in enumerate(sp):for ii, img in enumerate(pyr_level):img = img.squeeze()- assert_allclose(img, img.flip(1))- assert_allclose(img, img.flip(2))+ assert_close(img, img.flip(1))+ assert_close(img, img.flip(2))def test_gradcheck(self, device, dtype):img = torch.rand(1, 2, 7, 9, device=device, dtype=dtype)diff --git a/test/geometry/transform/test_thin_plate_spline.py b/test/geometry/transform/test_thin_plate_spline.pyindex 89270c369..e63cffae0 100644--- a/test/geometry/transform/test_thin_plate_spline.py+++ b/test/geometry/transform/test_thin_plate_spline.py@@ -1,9 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport kornia+from kornia.testing import assert_closedef _sample_points(batch_size, device, dtype=torch.float32):@@ -27,8 +27,8 @@ class TestTransformParameters:target_kernel = torch.zeros(batch_size, 5, 2, device=device)target_affine = torch.zeros(batch_size, 3, 2, device=device)target_affine[:, [1, 2], [0, 1]] = 1.0- assert_allclose(kernel, target_kernel, atol=1e-4, rtol=1e-4)- assert_allclose(affine, target_affine, atol=1e-4, rtol=1e-4)+ assert_close(kernel, target_kernel, atol=1e-4, rtol=1e-4)+ assert_close(affine, target_affine, atol=1e-4, rtol=1e-4)@pytest.mark.parametrize('batch_size', [1, 3])def test_affine_only(self, batch_size, device, dtype):@@ -37,7 +37,7 @@ class TestTransformParameters:)dst = src.clone() * 2.0kernel, affine = kornia.get_tps_transform(src, dst)- assert_allclose(kernel, torch.zeros_like(kernel), atol=1e-4, rtol=1e-4)+ assert_close(kernel, torch.zeros_like(kernel), atol=1e-4, rtol=1e-4)@pytest.mark.parametrize('batch_size', [1, 3])def test_exception(self, batch_size, device, dtype):@@ -67,8 +67,8 @@ class TestTransformParameters:op_jit = torch.jit.script(op)op_output = op(src, dst)jit_output = op_jit(src, dst)- assert_allclose(op_output[0], jit_output[0])- assert_allclose(op_output[1], jit_output[1])+ assert_close(op_output[0], jit_output[0])+ assert_close(op_output[1], jit_output[1])class TestWarpPoints:@@ -84,7 +84,7 @@ class TestWarpPoints:src, dst = _sample_points(batch_size, device)kernel, affine = kornia.get_tps_transform(src, dst)warp = kornia.warp_points_tps(src, dst, kernel, affine)- assert_allclose(warp, dst, atol=1e-4, rtol=1e-4)+ assert_close(warp, dst, atol=1e-4, rtol=1e-4)@pytest.mark.parametrize('batch_size', [1, 3])def test_exception(self, batch_size, device, dtype):@@ -138,7 +138,7 @@ class TestWarpPoints:kernel, affine = kornia.get_tps_transform(src, dst)op = kornia.warp_points_tpsop_jit = torch.jit.script(op)- assert_allclose(op(src, dst, kernel, affine), op_jit(src, dst, kernel, affine))+ assert_close(op(src, dst, kernel, affine), op_jit(src, dst, kernel, affine))class TestWarpImage:@@ -167,7 +167,7 @@ class TestWarpImage:kernel, affine = kornia.get_tps_transform(dst, src)warp = kornia.warp_image_tps(tensor, src, kernel, affine)- assert_allclose(warp, expected, atol=1e-4, rtol=1e-4)+ assert_close(warp, expected, atol=1e-4, rtol=1e-4)@pytest.mark.parametrize('batch_size', [1, 3])def test_exception(self, batch_size, device, dtype):@@ -223,4 +223,4 @@ class TestWarpImage:image = torch.rand(batch_size, 3, 32, 32, device=device)op = kornia.warp_image_tpsop_jit = torch.jit.script(op)- assert_allclose(op(image, dst, kernel, affine), op_jit(image, dst, kernel, affine), rtol=1e-4, atol=1e-4)+ assert_close(op(image, dst, kernel, affine), op_jit(image, dst, kernel, affine), rtol=1e-4, atol=1e-4)diff --git a/test/integration/test_conversions.py b/test/integration/test_conversions.pyindex 3cbb26cf7..e991a66a7 100644--- a/test/integration/test_conversions.py+++ b/test/integration/test_conversions.py@@ -1,10 +1,10 @@import numpy as npimport pytestimport torch-from torch.testing import assert_allcloseimport korniafrom kornia.geometry.conversions import QuaternionCoeffOrder+from kornia.testing import assert_close@pytest.fixture@@ -28,7 +28,7 @@ class TestAngleAxisToQuaternionToAngleAxis:angle_axis = torch.tensor((0.0, 0.0, 0.0), device=device, dtype=dtype)quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.WXYZ)angle_axis_hat = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(angle_axis_hat, angle_axis, atol=atol, rtol=rtol)+ assert_close(angle_axis_hat, angle_axis, atol=atol, rtol=rtol)@pytest.mark.parametrize("axis", (0, 1, 2))def test_small_angle(self, axis, device, dtype, atol, rtol):@@ -38,7 +38,7 @@ class TestAngleAxisToQuaternionToAngleAxis:angle_axis = torch.tensor(array, device=device, dtype=dtype)quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.WXYZ)angle_axis_hat = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(angle_axis_hat, angle_axis, atol=atol, rtol=rtol)+ assert_close(angle_axis_hat, angle_axis, atol=atol, rtol=rtol)@pytest.mark.parametrize("axis", (0, 1, 2))def test_rotation(self, axis, device, dtype, atol, rtol):@@ -48,7 +48,7 @@ class TestAngleAxisToQuaternionToAngleAxis:angle_axis = torch.tensor(array, device=device, dtype=dtype)quaternion = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.WXYZ)angle_axis_hat = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(angle_axis_hat, angle_axis, atol=atol, rtol=rtol)+ assert_close(angle_axis_hat, angle_axis, atol=atol, rtol=rtol)class TestQuaternionToAngleAxisToQuaternion:@@ -58,13 +58,13 @@ class TestQuaternionToAngleAxisToQuaternion:angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.XYZW)with pytest.warns(UserWarning):quaternion_hat = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion_hat, quaternion, atol=atol, rtol=rtol)+ assert_close(quaternion_hat, quaternion, atol=atol, rtol=rtol)def test_unit_quaternion(self, device, dtype, atol, rtol):quaternion = torch.tensor((1.0, 0.0, 0.0, 0.0), device=device, dtype=dtype)angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.WXYZ)quaternion_hat = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion_hat, quaternion, atol=atol, rtol=rtol)+ assert_close(quaternion_hat, quaternion, atol=atol, rtol=rtol)@pytest.mark.parametrize("axis", (0, 1, 2))def test_rotation_xyzw(self, axis, device, dtype, atol, rtol):@@ -75,7 +75,7 @@ class TestQuaternionToAngleAxisToQuaternion:angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.XYZW)with pytest.warns(UserWarning):quaternion_hat = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion_hat, quaternion, atol=atol, rtol=rtol)+ assert_close(quaternion_hat, quaternion, atol=atol, rtol=rtol)@pytest.mark.parametrize("axis", (0, 1, 2))def test_rotation(self, axis, device, dtype, atol, rtol):@@ -84,7 +84,7 @@ class TestQuaternionToAngleAxisToQuaternion:quaternion = torch.tensor(array, device=device, dtype=dtype)angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.WXYZ)quaternion_hat = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion_hat, quaternion, atol=atol, rtol=rtol)+ assert_close(quaternion_hat, quaternion, atol=atol, rtol=rtol)# just to be sure, check that mixing orders failswith pytest.warns(UserWarning):@@ -101,7 +101,7 @@ class TestQuaternionToAngleAxisToQuaternion:angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.XYZW)with pytest.warns(UserWarning):quaternion_hat = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion_hat, quaternion, atol=atol, rtol=rtol)+ assert_close(quaternion_hat, quaternion, atol=atol, rtol=rtol)@pytest.mark.parametrize("axis", (0, 1, 2))def test_small_angle(self, axis, device, dtype, atol, rtol):@@ -111,7 +111,7 @@ class TestQuaternionToAngleAxisToQuaternion:quaternion = torch.tensor(array, device=device, dtype=dtype)angle_axis = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.WXYZ)quaternion_hat = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion_hat, quaternion, atol=atol, rtol=rtol)+ assert_close(quaternion_hat, quaternion, atol=atol, rtol=rtol)# just to be sure, check that mixing orders failswith pytest.warns(UserWarning):@@ -137,11 +137,11 @@ class TestQuaternionToRotationMatrixToAngleAxis:angle_axis_expected = [[0.0, 0.0, 0.0]]angle_axis_expected[0][axis] = kornia.piangle_axis_expected = torch.tensor(angle_axis_expected, device=device, dtype=dtype)- assert_allclose(angle_axis, angle_axis_expected, atol=atol, rtol=rtol)+ assert_close(angle_axis, angle_axis_expected, atol=atol, rtol=rtol)with pytest.warns(UserWarning):quaternion_hat = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion_hat, quaternion, atol=atol, rtol=rtol)+ assert_close(quaternion_hat, quaternion, atol=atol, rtol=rtol)@pytest.mark.parametrize("axis", (0, 1, 2))def test_triplet_qma(self, axis, device, dtype, atol, rtol):@@ -159,10 +159,10 @@ class TestQuaternionToRotationMatrixToAngleAxis:angle_axis_expected = [[0.0, 0.0, 0.0]]angle_axis_expected[0][axis] = kornia.piangle_axis_expected = torch.tensor(angle_axis_expected, device=device, dtype=dtype)- assert_allclose(angle_axis, angle_axis_expected, atol=atol, rtol=rtol)+ assert_close(angle_axis, angle_axis_expected, atol=atol, rtol=rtol)quaternion_hat = kornia.angle_axis_to_quaternion(angle_axis, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion_hat, quaternion, atol=atol, rtol=rtol)+ assert_close(quaternion_hat, quaternion, atol=atol, rtol=rtol)@pytest.mark.parametrize("axis", (0, 1, 2))def test_triplet_qam_xyzw(self, axis, device, dtype, atol, rtol):@@ -181,7 +181,7 @@ class TestQuaternionToRotationMatrixToAngleAxis:with pytest.warns(UserWarning):quaternion_hat = kornia.rotation_matrix_to_quaternion(rot_m, order=QuaternionCoeffOrder.XYZW)- assert_allclose(quaternion_hat, quaternion, atol=atol, rtol=rtol)+ assert_close(quaternion_hat, quaternion, atol=atol, rtol=rtol)@pytest.mark.parametrize("axis", (0, 1, 2))def test_triplet_qam(self, axis, device, dtype, atol, rtol):@@ -198,7 +198,7 @@ class TestQuaternionToRotationMatrixToAngleAxis:assert rot_m.shape[-2] == 3quaternion_hat = kornia.rotation_matrix_to_quaternion(rot_m, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(quaternion_hat, quaternion, atol=atol, rtol=rtol)+ assert_close(quaternion_hat, quaternion, atol=atol, rtol=rtol)@pytest.mark.parametrize("axis", (0, 1, 2))def test_triplet_amq_xyzw(self, axis, device, dtype, atol, rtol):@@ -217,7 +217,7 @@ class TestQuaternionToRotationMatrixToAngleAxis:with pytest.warns(UserWarning):angle_axis_hat = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.XYZW)- assert_allclose(angle_axis_hat, angle_axis, atol=atol, rtol=rtol)+ assert_close(angle_axis_hat, angle_axis, atol=atol, rtol=rtol)@pytest.mark.parametrize("axis", (0, 1, 2))def test_triplet_amq(self, axis, device, dtype, atol, rtol):@@ -234,7 +234,7 @@ class TestQuaternionToRotationMatrixToAngleAxis:assert quaternion.shape[-1] == 4angle_axis_hat = kornia.quaternion_to_angle_axis(quaternion, order=QuaternionCoeffOrder.WXYZ)- assert_allclose(angle_axis_hat, angle_axis, atol=atol, rtol=rtol)+ assert_close(angle_axis_hat, angle_axis, atol=atol, rtol=rtol)@pytest.mark.parametrize("axis", (0, 1, 2))def test_triplet_aqm_xyzw(self, axis, device, dtype, atol, rtol):@@ -253,7 +253,7 @@ class TestQuaternionToRotationMatrixToAngleAxis:assert rot_m.shape[-2] == 3angle_axis_hat = kornia.rotation_matrix_to_angle_axis(rot_m)- assert_allclose(angle_axis_hat, angle_axis, atol=atol, rtol=rtol)+ assert_close(angle_axis_hat, angle_axis, atol=atol, rtol=rtol)@pytest.mark.parametrize("axis", (0, 1, 2))def test_triplet_aqm(self, axis, device, dtype, atol, rtol):@@ -270,7 +270,7 @@ class TestQuaternionToRotationMatrixToAngleAxis:assert rot_m.shape[-2] == 3angle_axis_hat = kornia.rotation_matrix_to_angle_axis(rot_m)- assert_allclose(angle_axis_hat, angle_axis, atol=atol, rtol=rtol)+ assert_close(angle_axis_hat, angle_axis, atol=atol, rtol=rtol)class TestAngleOfRotations:@@ -325,28 +325,28 @@ class TestAngleOfRotations:# Make sure the returned axis matches the named one, and the appropriate columnif axis_name == 'x':- assert_allclose(axis, torch.tensor(((1.0, 0.0, 0.0),) * angle.numel(), device=device, dtype=dtype))- assert_allclose(axis, rot_m[..., :3, 0])+ assert_close(axis, torch.tensor(((1.0, 0.0, 0.0),) * angle.numel(), device=device, dtype=dtype))+ assert_close(axis, rot_m[..., :3, 0])elif axis_name == 'y':- assert_allclose(axis, torch.tensor(((0.0, 1.0, 0.0),) * angle.numel(), device=device, dtype=dtype))- assert_allclose(axis, rot_m[..., :3, 1])+ assert_close(axis, torch.tensor(((0.0, 1.0, 0.0),) * angle.numel(), device=device, dtype=dtype))+ assert_close(axis, rot_m[..., :3, 1])elif axis_name == 'z':- assert_allclose(axis, torch.tensor(((0.0, 0.0, 1.0),) * angle.numel(), device=device, dtype=dtype))- assert_allclose(axis, rot_m[..., :3, 2])+ assert_close(axis, torch.tensor(((0.0, 0.0, 1.0),) * angle.numel(), device=device, dtype=dtype))+ assert_close(axis, rot_m[..., :3, 2])else:raise NotImplementedError(f'Not prepared for axis_name {axis_name}')# Make sure axes are perpendicularzero = torch.zeros_like(angle).unsqueeze(-1)- assert_allclose(rot_m[..., :3, 1:2].permute((0, 2, 1)) @ rot_m[..., :3, 0:1], zero, atol=atol, rtol=rtol)- assert_allclose(rot_m[..., :3, 2:3].permute((0, 2, 1)) @ rot_m[..., :3, 1:2], zero, atol=atol, rtol=rtol)- assert_allclose(rot_m[..., :3, 2:3].permute((0, 2, 1)) @ rot_m[..., :3, 0:1], zero, atol=atol, rtol=rtol)+ assert_close(rot_m[..., :3, 1:2].permute((0, 2, 1)) @ rot_m[..., :3, 0:1], zero, atol=atol, rtol=rtol)+ assert_close(rot_m[..., :3, 2:3].permute((0, 2, 1)) @ rot_m[..., :3, 1:2], zero, atol=atol, rtol=rtol)+ assert_close(rot_m[..., :3, 2:3].permute((0, 2, 1)) @ rot_m[..., :3, 0:1], zero, atol=atol, rtol=rtol)# Make sure axes are unit normone = torch.ones_like(angle)- assert_allclose(rot_m[..., :3, 0].norm(p=2, dim=-1, keepdim=True), one, atol=atol, rtol=rtol)- assert_allclose(rot_m[..., :3, 1].norm(p=2, dim=-1, keepdim=True), one, atol=atol, rtol=rtol)- assert_allclose(rot_m[..., :3, 2].norm(p=2, dim=-1, keepdim=True), one, atol=atol, rtol=rtol)+ assert_close(rot_m[..., :3, 0].norm(p=2, dim=-1, keepdim=True), one, atol=atol, rtol=rtol)+ assert_close(rot_m[..., :3, 1].norm(p=2, dim=-1, keepdim=True), one, atol=atol, rtol=rtol)+ assert_close(rot_m[..., :3, 2].norm(p=2, dim=-1, keepdim=True), one, atol=atol, rtol=rtol)@pytest.mark.parametrize('axis_name', ('x', 'y', 'z'))@pytest.mark.parametrize("angle_deg", (-179.9, -135.0, -90.0, -45.0, 0.0, 45, 90, 135, 179.9))@@ -356,7 +356,7 @@ class TestAngleOfRotations:axis_name=axis_name, angle=angle, device=device, dtype=dtype)matrix_angle_abs = TestAngleOfRotations.matrix_angle_abs(rot_m)- assert_allclose(torch.abs(angle), matrix_angle_abs)+ assert_close(torch.abs(angle), matrix_angle_abs)@pytest.mark.parametrize('axis_name', ('x', 'y', 'z'))@pytest.mark.parametrize("angle_deg", (-179.9, -90.0, -45.0, 0.0, 45, 90, 179.9))@@ -382,10 +382,10 @@ class TestAngleOfRotations:dots = (quaternion[..., :3] * axis).sum(dim=-1, keepdim=True)angle_hat = torch.where(dots < 0.0, angle_hat * -1.0, angle_hat)# quaternion angle should match input angle- assert_allclose(angle_hat, angle, atol=atol, rtol=rtol)+ assert_close(angle_hat, angle, atol=atol, rtol=rtol)# magnitude of angle should match matrix rotation anglematrix_angle_abs = TestAngleOfRotations.matrix_angle_abs(rot_m)- assert_allclose(torch.abs(angle_hat), matrix_angle_abs, atol=atol, rtol=rtol)+ assert_close(torch.abs(angle_hat), matrix_angle_abs, atol=atol, rtol=rtol)@pytest.mark.parametrize('axis_name', ('x', 'y', 'z'))@pytest.mark.parametrize("angle_deg", (-179.9, -90.0, -45.0, 0.0, 45, 90, 179.9))@@ -410,10 +410,10 @@ class TestAngleOfRotations:dots = (quaternion[..., 1:4] * axis).sum(dim=-1, keepdim=True)angle_hat = torch.where(dots < 0.0, angle_hat * -1.0, angle_hat)# quaternion angle should match input angle- assert_allclose(angle_hat, angle, atol=atol, rtol=rtol)+ assert_close(angle_hat, angle, atol=atol, rtol=rtol)# magnitude of angle should match matrix rotation anglematrix_angle_abs = TestAngleOfRotations.matrix_angle_abs(rot_m)- assert_allclose(torch.abs(angle_hat), matrix_angle_abs, atol=atol, rtol=rtol)+ assert_close(torch.abs(angle_hat), matrix_angle_abs, atol=atol, rtol=rtol)@pytest.mark.parametrize('axis_name', ('x', 'y', 'z'))@pytest.mark.parametrize("angle_deg", (-179.9, -90.0, -45.0, 0, 45, 90, 179.9))@@ -429,10 +429,10 @@ class TestAngleOfRotations:dots = (angle_axis * axis).sum(dim=-1, keepdim=True)angle_hat = torch.where(dots < 0.0, angle_hat * -1.0, angle_hat)# angle_axis angle should match input angle- assert_allclose(angle_hat, angle, atol=atol, rtol=rtol)+ assert_close(angle_hat, angle, atol=atol, rtol=rtol)# magnitude of angle should match matrix rotation anglematrix_angle_abs = TestAngleOfRotations.matrix_angle_abs(rot_m)- assert_allclose(torch.abs(angle_hat), matrix_angle_abs, atol=atol, rtol=rtol)+ assert_close(torch.abs(angle_hat), matrix_angle_abs, atol=atol, rtol=rtol)@pytest.mark.parametrize('axis_name', ('x', 'y', 'z'))@pytest.mark.parametrize("angle_deg", (-179.9, -90.0, -45.0, 0, 45, 90, 179.9))@@ -458,10 +458,10 @@ class TestAngleOfRotations:dots = (log_q * axis).sum(dim=-1, keepdim=True)angle_hat = torch.where(dots < 0.0, angle_hat * -1.0, angle_hat)# angle_axis angle should match input angle- assert_allclose(angle_hat, angle, atol=atol, rtol=rtol)+ assert_close(angle_hat, angle, atol=atol, rtol=rtol)# magnitude of angle should match matrix rotation anglematrix_angle_abs = TestAngleOfRotations.matrix_angle_abs(rot_m)- assert_allclose(torch.abs(angle_hat), matrix_angle_abs, atol=atol, rtol=rtol)+ assert_close(torch.abs(angle_hat), matrix_angle_abs, atol=atol, rtol=rtol)@pytest.mark.parametrize('axis_name', ('x', 'y', 'z'))@pytest.mark.parametrize("angle_deg", (-179.9, -90.0, -45.0, 0, 45, 90, 179.9))@@ -485,7 +485,7 @@ class TestAngleOfRotations:dots = (log_q * axis).sum(dim=-1, keepdim=True)angle_hat = torch.where(dots < 0.0, angle_hat * -1.0, angle_hat)# angle_axis angle should match input angle- assert_allclose(angle_hat, angle, atol=atol, rtol=rtol)+ assert_close(angle_hat, angle, atol=atol, rtol=rtol)# magnitude of angle should match matrix rotation anglematrix_angle_abs = TestAngleOfRotations.matrix_angle_abs(rot_m)- assert_allclose(torch.abs(angle_hat), matrix_angle_abs, atol=atol, rtol=rtol)+ assert_close(torch.abs(angle_hat), matrix_angle_abs, atol=atol, rtol=rtol)diff --git a/test/integration/test_soft_argmax2d.py b/test/integration/test_soft_argmax2d.pyindex 4a15db1dc..995d4453c 100644--- a/test/integration/test_soft_argmax2d.py+++ b/test/integration/test_soft_argmax2d.py@@ -3,9 +3,9 @@ import loggingimport torchimport torch.nn as nnimport torch.optim as optim-from torch.testing import assert_allcloseimport kornia+from kornia.testing import assert_closelogger = logging.getLogger(__name__)@@ -58,5 +58,5 @@ class TestIntegrationSoftArgmax2d:loss.backward()optimizer.step()- assert_allclose(pred[..., 0], target[..., 0], rtol=1e-2, atol=1e-2)- assert_allclose(pred[..., 1], target[..., 1], rtol=1e-2, atol=1e-2)+ assert_close(pred[..., 0], target[..., 0], rtol=1e-2, atol=1e-2)+ assert_close(pred[..., 1], target[..., 1], rtol=1e-2, atol=1e-2)diff --git a/test/morphology/test_bottom_hat.py b/test/morphology/test_bottom_hat.pyindex 5bdffef40..8800782c7 100644--- a/test/morphology/test_bottom_hat.py+++ b/test/morphology/test_bottom_hat.py@@ -1,9 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allclosefrom kornia.morphology import bottom_hat+from kornia.testing import assert_closeclass TestBottomHat:@@ -26,7 +26,7 @@ class TestBottomHat:expected = torch.tensor([[0.2, 0.0, 0.5], [0.0, 0.4, 0.0], [0.3, 0.0, 0.6]], device=device, dtype=dtype)[None, None, :, :]- assert_allclose(bottom_hat(tensor, kernel), expected, atol=1e-3, rtol=1e-3)+ assert_close(bottom_hat(tensor, kernel), expected, atol=1e-3, rtol=1e-3)def test_structural_element(self, device, dtype):tensor = torch.tensor([[0.5, 1.0, 0.3], [0.7, 0.3, 0.8], [0.4, 0.9, 0.2]], device=device, dtype=dtype)[@@ -38,7 +38,7 @@ class TestBottomHat:expected = torch.tensor([[0.2, 0.0, 0.5], [0.0, 0.4, 0.0], [0.3, 0.0, 0.6]], device=device, dtype=dtype)[None, None, :, :]- assert_allclose(+ assert_close(bottom_hat(tensor, torch.ones_like(structural_element), structuring_element=structural_element),expected,atol=1e-3,@@ -80,4 +80,4 @@ class TestBottomHat:actual = op_script(input, kernel)expected = op(input, kernel)- assert_allclose(actual, expected)+ assert_close(actual, expected)diff --git a/test/morphology/test_closing.py b/test/morphology/test_closing.pyindex 529beab03..68f2907cb 100644--- a/test/morphology/test_closing.py+++ b/test/morphology/test_closing.py@@ -1,9 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allclosefrom kornia.morphology import closing+from kornia.testing import assert_closeclass TestClosing:@@ -26,7 +26,7 @@ class TestClosing:expected = torch.tensor([[0.7, 1.0, 0.8], [0.7, 0.7, 0.8], [0.7, 0.9, 0.8]], device=device, dtype=dtype)[None, None, :, :]- assert_allclose(closing(tensor, kernel), expected, atol=1e-4, rtol=1e-4)+ assert_close(closing(tensor, kernel), expected, atol=1e-4, rtol=1e-4)def test_structural_element(self, device, dtype):tensor = torch.tensor([[0.5, 1.0, 0.3], [0.7, 0.3, 0.8], [0.4, 0.9, 0.2]], device=device, dtype=dtype)[@@ -38,7 +38,7 @@ class TestClosing:expected = torch.tensor([[0.7, 1.0, 0.8], [0.7, 0.7, 0.8], [0.7, 0.9, 0.8]], device=device, dtype=dtype)[None, None, :, :]- assert_allclose(+ assert_close(closing(tensor, torch.ones_like(structural_element), structuring_element=structural_element),expected,atol=1e-4,@@ -80,4 +80,4 @@ class TestClosing:actual = op_script(tensor, kernel)expected = op(tensor, kernel)- assert_allclose(actual, expected)+ assert_close(actual, expected)diff --git a/test/morphology/test_dilation.py b/test/morphology/test_dilation.pyindex 5e6f092de..ceaee8847 100644--- a/test/morphology/test_dilation.py+++ b/test/morphology/test_dilation.py@@ -1,9 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allclosefrom kornia.morphology import dilation+from kornia.testing import assert_closeclass TestDilate:@@ -26,7 +26,7 @@ class TestDilate:expected = torch.tensor([[1.0, 1.0, 1.0], [0.7, 1.0, 0.8], [0.9, 0.9, 0.9]], device=device, dtype=dtype)[None, None, :, :]- assert_allclose(dilation(tensor, kernel), expected, atol=1e-4, rtol=1e-4)+ assert_close(dilation(tensor, kernel), expected, atol=1e-4, rtol=1e-4)def test_structural_element(self, device, dtype):tensor = torch.tensor([[0.5, 1.0, 0.3], [0.7, 0.3, 0.8], [0.4, 0.9, 0.2]], device=device, dtype=dtype)[@@ -38,7 +38,7 @@ class TestDilate:expected = torch.tensor([[1.0, 1.0, 1.0], [0.7, 1.0, 0.8], [0.9, 0.9, 0.9]], device=device, dtype=dtype)[None, None, :, :]- assert_allclose(+ assert_close(dilation(tensor, torch.ones_like(structural_element), structuring_element=structural_element),expected,atol=1e-4,@@ -80,4 +80,4 @@ class TestDilate:actual = op_script(tensor, kernel)expected = op(tensor, kernel)- assert_allclose(actual, expected)+ assert_close(actual, expected)diff --git a/test/morphology/test_erosion.py b/test/morphology/test_erosion.pyindex 2c03e4dfe..9ad88f2e4 100644--- a/test/morphology/test_erosion.py+++ b/test/morphology/test_erosion.py@@ -1,9 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allclosefrom kornia.morphology import erosion+from kornia.testing import assert_closeclass TestErode:@@ -26,7 +26,7 @@ class TestErode:expected = torch.tensor([[0.5, 0.3, 0.3], [0.3, 0.3, 0.2], [0.4, 0.2, 0.2]], device=device, dtype=dtype)[None, None, :, :]- assert_allclose(erosion(tensor, kernel), expected, atol=1e-4, rtol=1e-4)+ assert_close(erosion(tensor, kernel), expected, atol=1e-4, rtol=1e-4)def test_structural_element(self, device, dtype):tensor = torch.tensor([[0.5, 1.0, 0.3], [0.7, 0.3, 0.8], [0.4, 0.9, 0.2]], device=device, dtype=dtype)[@@ -38,7 +38,7 @@ class TestErode:expected = torch.tensor([[0.5, 0.3, 0.3], [0.3, 0.3, 0.2], [0.4, 0.2, 0.2]], device=device, dtype=dtype)[None, None, :, :]- assert_allclose(+ assert_close(erosion(tensor, torch.ones_like(structural_element), structuring_element=structural_element),expected,atol=1e-4,@@ -80,4 +80,4 @@ class TestErode:actual = op_script(tensor, kernel)expected = op(tensor, kernel)- assert_allclose(actual, expected)+ assert_close(actual, expected)diff --git a/test/morphology/test_gradient.py b/test/morphology/test_gradient.pyindex 3df74f07f..a43dd7d84 100644--- a/test/morphology/test_gradient.py+++ b/test/morphology/test_gradient.py@@ -1,9 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allclosefrom kornia.morphology import gradient+from kornia.testing import assert_closeclass TestGradient:@@ -26,7 +26,7 @@ class TestGradient:expected = torch.tensor([[0.5, 0.7, 0.7], [0.4, 0.7, 0.6], [0.5, 0.7, 0.7]], device=device, dtype=dtype)[None, None, :, :]- assert_allclose(gradient(tensor, kernel), expected, atol=1e-3, rtol=1e-3)+ assert_close(gradient(tensor, kernel), expected, atol=1e-3, rtol=1e-3)def test_structural_element(self, device, dtype):tensor = torch.tensor([[0.5, 1.0, 0.3], [0.7, 0.3, 0.8], [0.4, 0.9, 0.2]], device=device, dtype=dtype)[@@ -38,7 +38,7 @@ class TestGradient:expected = torch.tensor([[0.5, 0.7, 0.7], [0.4, 0.7, 0.6], [0.5, 0.7, 0.7]], device=device, dtype=dtype)[None, None, :, :]- assert_allclose(+ assert_close(gradient(tensor, torch.ones_like(structural_element), structuring_element=structural_element),expected,atol=1e-3,@@ -80,4 +80,4 @@ class TestGradient:actual = op_script(tensor, kernel)expected = op(tensor, kernel)- assert_allclose(actual, expected)+ assert_close(actual, expected)diff --git a/test/morphology/test_opening.py b/test/morphology/test_opening.pyindex e4631f0db..5d934dab6 100644--- a/test/morphology/test_opening.py+++ b/test/morphology/test_opening.py@@ -1,9 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allclosefrom kornia.morphology import opening+from kornia.testing import assert_closeclass TestOpening:@@ -26,7 +26,7 @@ class TestOpening:expected = torch.tensor([[0.5, 0.5, 0.3], [0.5, 0.3, 0.3], [0.4, 0.4, 0.2]], device=device, dtype=dtype)[None, None, :, :]- assert_allclose(opening(tensor, kernel), expected, atol=1e-4, rtol=1e-4)+ assert_close(opening(tensor, kernel), expected, atol=1e-4, rtol=1e-4)def test_structural_element(self, device, dtype):tensor = torch.tensor([[0.5, 1.0, 0.3], [0.7, 0.3, 0.8], [0.4, 0.9, 0.2]], device=device, dtype=dtype)[@@ -38,7 +38,7 @@ class TestOpening:expected = torch.tensor([[0.5, 0.5, 0.3], [0.5, 0.3, 0.3], [0.4, 0.4, 0.2]], device=device, dtype=dtype)[None, None, :, :]- assert_allclose(+ assert_close(opening(tensor, torch.ones_like(structural_element), structuring_element=structural_element),expected,atol=1e-4,@@ -80,4 +80,4 @@ class TestOpening:actual = op_script(tensor, kernel)expected = op(tensor, kernel)- assert_allclose(actual, expected)+ assert_close(actual, expected)diff --git a/test/morphology/test_top_hat.py b/test/morphology/test_top_hat.pyindex 8329e8376..d52438470 100644--- a/test/morphology/test_top_hat.py+++ b/test/morphology/test_top_hat.py@@ -1,9 +1,9 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allclosefrom kornia.morphology import top_hat+from kornia.testing import assert_closeclass TestTopHat:@@ -26,7 +26,7 @@ class TestTopHat:expected = torch.tensor([[0.0, 0.5, 0.0], [0.2, 0.0, 0.5], [0.0, 0.5, 0.0]], device=device, dtype=dtype)[None, None, :, :]- assert_allclose(top_hat(tensor, kernel), expected, atol=1e-3, rtol=1e-3)+ assert_close(top_hat(tensor, kernel), expected, atol=1e-3, rtol=1e-3)def test_structural_element(self, device, dtype):tensor = torch.tensor([[0.5, 1.0, 0.3], [0.7, 0.3, 0.8], [0.4, 0.9, 0.2]], device=device, dtype=dtype)[@@ -38,7 +38,7 @@ class TestTopHat:expected = torch.tensor([[0.0, 0.5, 0.0], [0.2, 0.0, 0.5], [0.0, 0.5, 0.0]], device=device, dtype=dtype)[None, None, :, :]- assert_allclose(+ assert_close(top_hat(tensor, torch.ones_like(structural_element), structuring_element=structural_element),expected,atol=1e-3,@@ -80,4 +80,4 @@ class TestTopHat:actual = op_script(input, kernel)expected = op(input, kernel)- assert_allclose(actual, expected)+ assert_close(actual, expected)diff --git a/test/test_contrib.py b/test/test_contrib.pyindex db6d89efe..c276e6160 100644--- a/test/test_contrib.py+++ b/test/test_contrib.py@@ -1,10 +1,10 @@import pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestMaxBlurPool2d:@@ -32,7 +32,7 @@ class TestMaxBlurPool2d:img = torch.rand(2, 3, 4, 5).to(device)actual = op_script(img, kernel_size=3)expected = kornia.contrib.max_blur_pool2d(img, kernel_size=3)- assert_allclose(actual, expected)+ assert_close(actual, expected)class TestExtractTensorPatches:@@ -46,10 +46,10 @@ class TestExtractTensorPatches:m = kornia.contrib.ExtractTensorPatches(3)patches = m(input)assert patches.shape == (1, 4, 1, 3, 3)- assert_allclose(input[0, :, :3, :3], patches[0, 0])- assert_allclose(input[0, :, :3, 1:], patches[0, 1])- assert_allclose(input[0, :, 1:, :3], patches[0, 2])- assert_allclose(input[0, :, 1:, 1:], patches[0, 3])+ assert_close(input[0, :, :3, :3], patches[0, 0])+ assert_close(input[0, :, :3, 1:], patches[0, 1])+ assert_close(input[0, :, 1:, :3], patches[0, 2])+ assert_close(input[0, :, 1:, 1:], patches[0, 3])def test_b1_ch2_h4w4_ws3(self, device):input = torch.arange(16.0).view(1, 1, 4, 4).to(device)@@ -57,50 +57,50 @@ class TestExtractTensorPatches:m = kornia.contrib.ExtractTensorPatches(3)patches = m(input)assert patches.shape == (1, 4, 2, 3, 3)- assert_allclose(input[0, :, :3, :3], patches[0, 0])- assert_allclose(input[0, :, :3, 1:], patches[0, 1])- assert_allclose(input[0, :, 1:, :3], patches[0, 2])- assert_allclose(input[0, :, 1:, 1:], patches[0, 3])+ assert_close(input[0, :, :3, :3], patches[0, 0])+ assert_close(input[0, :, :3, 1:], patches[0, 1])+ assert_close(input[0, :, 1:, :3], patches[0, 2])+ assert_close(input[0, :, 1:, 1:], patches[0, 3])def test_b1_ch1_h4w4_ws2(self, device):input = torch.arange(16.0).view(1, 1, 4, 4).to(device)m = kornia.contrib.ExtractTensorPatches(2)patches = m(input)assert patches.shape == (1, 9, 1, 2, 2)- assert_allclose(input[0, :, 0:2, 1:3], patches[0, 1])- assert_allclose(input[0, :, 0:2, 2:4], patches[0, 2])- assert_allclose(input[0, :, 1:3, 1:3], patches[0, 4])- assert_allclose(input[0, :, 2:4, 1:3], patches[0, 7])+ assert_close(input[0, :, 0:2, 1:3], patches[0, 1])+ assert_close(input[0, :, 0:2, 2:4], patches[0, 2])+ assert_close(input[0, :, 1:3, 1:3], patches[0, 4])+ assert_close(input[0, :, 2:4, 1:3], patches[0, 7])def test_b1_ch1_h4w4_ws2_stride2(self, device):input = torch.arange(16.0).view(1, 1, 4, 4).to(device)m = kornia.contrib.ExtractTensorPatches(2, stride=2)patches = m(input)assert patches.shape == (1, 4, 1, 2, 2)- assert_allclose(input[0, :, 0:2, 0:2], patches[0, 0])- assert_allclose(input[0, :, 0:2, 2:4], patches[0, 1])- assert_allclose(input[0, :, 2:4, 0:2], patches[0, 2])- assert_allclose(input[0, :, 2:4, 2:4], patches[0, 3])+ assert_close(input[0, :, 0:2, 0:2], patches[0, 0])+ assert_close(input[0, :, 0:2, 2:4], patches[0, 1])+ assert_close(input[0, :, 2:4, 0:2], patches[0, 2])+ assert_close(input[0, :, 2:4, 2:4], patches[0, 3])def test_b1_ch1_h4w4_ws2_stride21(self, device):input = torch.arange(16.0).view(1, 1, 4, 4).to(device)m = kornia.contrib.ExtractTensorPatches(2, stride=(2, 1))patches = m(input)assert patches.shape == (1, 6, 1, 2, 2)- assert_allclose(input[0, :, 0:2, 1:3], patches[0, 1])- assert_allclose(input[0, :, 0:2, 2:4], patches[0, 2])- assert_allclose(input[0, :, 2:4, 0:2], patches[0, 3])- assert_allclose(input[0, :, 2:4, 2:4], patches[0, 5])+ assert_close(input[0, :, 0:2, 1:3], patches[0, 1])+ assert_close(input[0, :, 0:2, 2:4], patches[0, 2])+ assert_close(input[0, :, 2:4, 0:2], patches[0, 3])+ assert_close(input[0, :, 2:4, 2:4], patches[0, 5])def test_b1_ch1_h3w3_ws2_stride1_padding1(self, device):input = torch.arange(9.0).view(1, 1, 3, 3).to(device)m = kornia.contrib.ExtractTensorPatches(2, stride=1, padding=1)patches = m(input)assert patches.shape == (1, 16, 1, 2, 2)- assert_allclose(input[0, :, 0:2, 0:2], patches[0, 5])- assert_allclose(input[0, :, 0:2, 1:3], patches[0, 6])- assert_allclose(input[0, :, 1:3, 0:2], patches[0, 9])- assert_allclose(input[0, :, 1:3, 1:3], patches[0, 10])+ assert_close(input[0, :, 0:2, 0:2], patches[0, 5])+ assert_close(input[0, :, 0:2, 1:3], patches[0, 6])+ assert_close(input[0, :, 1:3, 0:2], patches[0, 9])+ assert_close(input[0, :, 1:3, 1:3], patches[0, 10])def test_b2_ch1_h3w3_ws2_stride1_padding1(self, device):batch_size = 2@@ -110,28 +110,28 @@ class TestExtractTensorPatches:patches = m(input)assert patches.shape == (batch_size, 16, 1, 2, 2)for i in range(batch_size):- assert_allclose(input[i, :, 0:2, 0:2], patches[i, 5])- assert_allclose(input[i, :, 0:2, 1:3], patches[i, 6])- assert_allclose(input[i, :, 1:3, 0:2], patches[i, 9])- assert_allclose(input[i, :, 1:3, 1:3], patches[i, 10])+ assert_close(input[i, :, 0:2, 0:2], patches[i, 5])+ assert_close(input[i, :, 0:2, 1:3], patches[i, 6])+ assert_close(input[i, :, 1:3, 0:2], patches[i, 9])+ assert_close(input[i, :, 1:3, 1:3], patches[i, 10])def test_b1_ch1_h3w3_ws23(self, device):input = torch.arange(9.0).view(1, 1, 3, 3).to(device)m = kornia.contrib.ExtractTensorPatches((2, 3))patches = m(input)assert patches.shape == (1, 2, 1, 2, 3)- assert_allclose(input[0, :, 0:2, 0:3], patches[0, 0])- assert_allclose(input[0, :, 1:3, 0:3], patches[0, 1])+ assert_close(input[0, :, 0:2, 0:3], patches[0, 0])+ assert_close(input[0, :, 1:3, 0:3], patches[0, 1])def test_b1_ch1_h3w4_ws23(self, device):input = torch.arange(12.0).view(1, 1, 3, 4).to(device)m = kornia.contrib.ExtractTensorPatches((2, 3))patches = m(input)assert patches.shape == (1, 4, 1, 2, 3)- assert_allclose(input[0, :, 0:2, 0:3], patches[0, 0])- assert_allclose(input[0, :, 0:2, 1:4], patches[0, 1])- assert_allclose(input[0, :, 1:3, 0:3], patches[0, 2])- assert_allclose(input[0, :, 1:3, 1:4], patches[0, 3])+ assert_close(input[0, :, 0:2, 0:3], patches[0, 0])+ assert_close(input[0, :, 0:2, 1:4], patches[0, 1])+ assert_close(input[0, :, 1:3, 0:3], patches[0, 2])+ assert_close(input[0, :, 1:3, 1:4], patches[0, 3])@pytest.mark.skip(reason="turn off all jit for a while")def test_jit(self, device):@@ -145,7 +145,7 @@ class TestExtractTensorPatches:actual = op_script(grid, height, width)expected = kornia.denormalize_pixel_coordinates(grid, height, width)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_gradcheck(self, device):input = torch.rand(2, 3, 4, 4).to(device)diff --git a/test/test_losses.py b/test/test_losses.pyindex 17f6ac8e2..e4710a97c 100644--- a/test/test_losses.py+++ b/test/test_losses.py@@ -3,10 +3,10 @@ import mathimport pytestimport torchfrom torch.autograd import gradcheck-from torch.testing import assert_allcloseimport korniaimport kornia.testing as utils # test utils+from kornia.testing import assert_closeclass TestBinaryFocalLossWithLogits:@@ -58,7 +58,7 @@ class TestBinaryFocalLossWithLogits:op_script = torch.jit.script(op)actual = op_script(logits, labels, alpha=0.5, gamma=2.0, reduction="none")expected = op(logits, labels, alpha=0.5, gamma=2.0, reduction="none")- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_gradcheck(self, device):num_classes = 1@@ -138,7 +138,7 @@ class TestFocalLoss:actual = op_script(logits, labels, *params)expected = op(logits, labels, *params)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_module(self, device, dtype):num_classes = 3@@ -152,7 +152,7 @@ class TestFocalLoss:actual = op_module(logits, labels)expected = op(logits, labels, *params)- assert_allclose(actual, expected)+ assert_close(actual, expected)class TestTverskyLoss:@@ -175,7 +175,7 @@ class TestTverskyLoss:criterion = kornia.losses.TverskyLoss(alpha=0.5, beta=0.5)loss = criterion(logits, labels)- assert_allclose(loss, torch.zeros_like(loss), atol=1e-3, rtol=1e-3)+ assert_close(loss, torch.zeros_like(loss), atol=1e-3, rtol=1e-3)def test_gradcheck(self, device, dtype):num_classes = 3@@ -199,7 +199,7 @@ class TestTverskyLoss:actual = op_script(logits, labels, *params)expected = op(logits, labels, *params)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_module(self, device, dtype):num_classes = 3@@ -213,7 +213,7 @@ class TestTverskyLoss:actual = op_module(logits, labels)expected = op(logits, labels, *params)- assert_allclose(actual, expected)+ assert_close(actual, expected)class TestDiceLoss:@@ -236,7 +236,7 @@ class TestDiceLoss:criterion = kornia.losses.DiceLoss()loss = criterion(logits, labels)- assert_allclose(loss, torch.zeros_like(loss), rtol=1e-3, atol=1e-3)+ assert_close(loss, torch.zeros_like(loss), rtol=1e-3, atol=1e-3)def test_gradcheck(self, device, dtype):num_classes = 3@@ -256,7 +256,7 @@ class TestDiceLoss:op = kornia.losses.dice_lossop_script = torch.jit.script(op)- assert_allclose(op(logits, labels), op_script(logits, labels))+ assert_close(op(logits, labels), op_script(logits, labels))def test_module(self, device, dtype):num_classes = 3@@ -267,7 +267,7 @@ class TestDiceLoss:op = kornia.losses.dice_lossop_module = kornia.losses.DiceLoss()- assert_allclose(op(logits, labels), op_module(logits, labels))+ assert_close(op(logits, labels), op_module(logits, labels))class TestDepthSmoothnessLoss:@@ -286,7 +286,7 @@ class TestDepthSmoothnessLoss:op = kornia.losses.inverse_depth_smoothness_lossop_script = torch.jit.script(op)- assert_allclose(op(image, depth), op_script(image, depth))+ assert_close(op(image, depth), op_script(image, depth))def test_module(self, device, dtype):image = torch.rand(1, 2, 3, 4, device=device, dtype=dtype)@@ -295,7 +295,7 @@ class TestDepthSmoothnessLoss:op = kornia.losses.inverse_depth_smoothness_lossop_module = kornia.losses.InverseDepthSmoothnessLoss()- assert_allclose(op(image, depth), op_module(image, depth))+ assert_close(op(image, depth), op_module(image, depth))def test_gradcheck(self, device, dtype):image = torch.rand(1, 2, 3, 4, device=device, dtype=dtype)@@ -315,8 +315,8 @@ class TestSSIMLoss:ssim2 = kornia.losses.ssim_loss(img2, img2, window_size=5, reduction="none")tol_val: float = utils._get_precision_by_name(device, 'xla', 1e-1, 1e-4)- assert_allclose(ssim1, torch.zeros_like(img1), rtol=tol_val, atol=tol_val)- assert_allclose(ssim2, torch.zeros_like(img2), rtol=tol_val, atol=tol_val)+ assert_close(ssim1, torch.zeros_like(img1), rtol=tol_val, atol=tol_val)+ assert_close(ssim2, torch.zeros_like(img2), rtol=tol_val, atol=tol_val)@pytest.mark.parametrize("window_size", [5, 11])@pytest.mark.parametrize("reduction_type", ["mean", "sum"])@@ -331,7 +331,7 @@ class TestSSIMLoss:loss = kornia.losses.ssim_loss(img, img, window_size, reduction=reduction_type)tol_val: float = utils._get_precision_by_name(device, 'xla', 1e-1, 1e-4)- assert_allclose(loss.item(), 0.0, rtol=tol_val, atol=tol_val)+ assert_close(loss.item(), 0.0, rtol=tol_val, atol=tol_val)def test_jit(self, device, dtype):img1 = torch.rand(1, 2, 3, 4, device=device, dtype=dtype)@@ -342,7 +342,7 @@ class TestSSIMLoss:op = kornia.losses.ssim_lossop_script = torch.jit.script(op)- assert_allclose(op(*args), op_script(*args))+ assert_close(op(*args), op_script(*args))def test_module(self, device, dtype):img1 = torch.rand(1, 2, 3, 4, device=device, dtype=dtype)@@ -353,7 +353,7 @@ class TestSSIMLoss:op = kornia.losses.ssim_lossop_module = kornia.losses.SSIMLoss(*args[2:])- assert_allclose(op(*args), op_module(*args[:2]))+ assert_close(op(*args), op_module(*args[:2]))def test_gradcheck(self, device, dtype):# input data@@ -381,7 +381,7 @@ class TestDivergenceLoss:)def test_js_div_loss_2d(self, device, dtype, input, target, expected):actual = kornia.losses.js_div_loss_2d(input.to(device, dtype), target.to(device, dtype))- assert_allclose(actual.item(), expected)+ assert_close(actual.item(), expected)@pytest.mark.parametrize('input,target,expected',@@ -394,7 +394,7 @@ class TestDivergenceLoss:)def test_kl_div_loss_2d(self, device, dtype, input, target, expected):actual = kornia.losses.kl_div_loss_2d(input.to(device, dtype), target.to(device, dtype))- assert_allclose(actual.item(), expected)+ assert_close(actual.item(), expected)@pytest.mark.parametrize('input,target,expected',@@ -407,7 +407,7 @@ class TestDivergenceLoss:)def test_kl_div_loss_2d_without_reduction(self, device, dtype, input, target, expected):actual = kornia.losses.kl_div_loss_2d(input.to(device, dtype), target.to(device, dtype), reduction='none')- assert_allclose(actual, expected.to(device, dtype))+ assert_close(actual, expected.to(device, dtype))@pytest.mark.parametrize('input,target,expected',@@ -422,7 +422,7 @@ class TestDivergenceLoss:input = input.to(device, dtype).view(input.shape[::-1]).Ttarget = target.to(device, dtype).view(target.shape[::-1]).Tactual = kornia.losses.kl_div_loss_2d(input, target).item()- assert_allclose(actual, expected)+ assert_close(actual, expected)@pytest.mark.parametrize('input,target,expected',@@ -437,7 +437,7 @@ class TestDivergenceLoss:input = input.to(device, dtype).view(input.shape[::-1]).Ttarget = target.to(device, dtype).view(target.shape[::-1]).Tactual = kornia.losses.js_div_loss_2d(input, target).item()- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_gradcheck_kl(self, device, dtype):input = torch.rand(1, 1, 10, 16, device=device, dtype=dtype)@@ -463,7 +463,7 @@ class TestDivergenceLoss:args = (input, target)op = kornia.losses.kl_div_loss_2dop_jit = torch.jit.script(op, args)- assert_allclose(op(*args), op_jit(*args), rtol=0, atol=1e-5)+ assert_close(op(*args), op_jit(*args), rtol=0, atol=1e-5)def test_jit_js(self, device, dtype):input = torch.randn((2, 4, 10, 16), dtype=dtype, device=device)@@ -471,7 +471,7 @@ class TestDivergenceLoss:args = (input, target)op = kornia.losses.js_div_loss_2dop_jit = torch.jit.script(op, args)- assert_allclose(op(*args), op_jit(*args), rtol=0, atol=1e-5)+ assert_close(op(*args), op_jit(*args), rtol=0, atol=1e-5)class TestTotalVariation:@@ -481,7 +481,7 @@ class TestTotalVariation:)def test_tv_on_constant(self, device, dtype, input, expected):actual = kornia.losses.total_variation(input.to(device, dtype))- assert_allclose(actual, expected.to(device, dtype))+ assert_close(actual, expected.to(device, dtype))# Total variation for 3D tensors@pytest.mark.parametrize(@@ -520,7 +520,7 @@ class TestTotalVariation:)def test_tv_on_3d(self, device, dtype, input, expected):actual = kornia.losses.total_variation(input.to(device, dtype))- assert_allclose(actual, expected.to(device, dtype))+ assert_close(actual, expected.to(device, dtype))# Total variation for 4D tensors@pytest.mark.parametrize(@@ -557,7 +557,7 @@ class TestTotalVariation:)def test_tv_on_4d(self, device, dtype, input, expected):actual = kornia.losses.total_variation(input.to(device, dtype))- assert_allclose(actual, expected.to(device, dtype), rtol=1e-4, atol=1e-4)+ assert_close(actual, expected.to(device, dtype), rtol=1e-4, atol=1e-4)# Expect ValueError to be raised when tensors of ndim != 3 or 4 are passed@pytest.mark.parametrize('input', [torch.rand(2, 3, 4, 5, 3), torch.rand(3, 1)])@@ -577,7 +577,7 @@ class TestTotalVariation:op = kornia.losses.total_variationop_script = torch.jit.script(op)- assert_allclose(op(image), op_script(image))+ assert_close(op(image), op_script(image))def test_module(self, device, dtype):image = torch.rand(1, 2, 3, 4, device=device, dtype=dtype)@@ -585,7 +585,7 @@ class TestTotalVariation:op = kornia.losses.total_variationop_module = kornia.losses.TotalVariation()- assert_allclose(op(image), op_module(image))+ assert_close(op(image), op_module(image))def test_gradcheck(self, device, dtype):image = torch.rand(1, 2, 3, 4, device=device, dtype=dtype)@@ -621,13 +621,13 @@ class TestPSNRLoss:input = torch.ones(1, device=device, dtype=dtype)expected = torch.tensor(20.0, device=device, dtype=dtype)actual = kornia.losses.psnr(input, 1.2 * input, 2.0)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_loss(self, device, dtype):input = torch.ones(1, device=device, dtype=dtype)expected = torch.tensor(-20.0, device=device, dtype=dtype)actual = kornia.losses.psnr_loss(input, 1.2 * input, 2.0)- assert_allclose(actual, expected)+ assert_close(actual, expected)def test_jit(self, device, dtype):input = torch.rand(2, 3, 3, 2, device=device, dtype=dtype)@@ -638,7 +638,7 @@ class TestPSNRLoss:op = kornia.losses.psnr_lossop_script = torch.jit.script(op)- assert_allclose(op(*args), op_script(*args))+ assert_close(op(*args), op_script(*args))def test_module(self, device, dtype):input = torch.rand(2, 3, 3, 2, device=device, dtype=dtype)@@ -649,7 +649,7 @@ class TestPSNRLoss:op = kornia.losses.psnr_lossop_module = kornia.losses.PSNRLoss(1.0)- assert_allclose(op(*args), op_module(input, target))+ assert_close(op(*args), op_module(input, target))def test_gradcheck(self, device, dtype):input = torch.rand(2, 3, 3, 2, device=device, dtype=dtype)diff --git a/test/utils/test_grid.py b/test/utils/test_grid.pyindex 114fdd0a5..5214a0e7a 100644--- a/test/utils/test_grid.py+++ b/test/utils/test_grid.py@@ -1,8 +1,8 @@import pytestimport torch-from torch.testing import assert_allcloseimport kornia+from kornia.testing import assert_closedef test_create_meshgrid(device, dtype):@@ -48,8 +48,8 @@ def test_normalize_pixel_grid(device, dtype):# transform gridsgrid_pix_to_norm = kornia.transform_points(norm_trans_pix, grid_pix)grid_norm_to_pix = kornia.transform_points(pix_trans_norm, grid_norm)- assert_allclose(grid_pix, grid_norm_to_pix)- assert_allclose(grid_norm, grid_pix_to_norm)+ assert_close(grid_pix, grid_norm_to_pix)+ assert_close(grid_norm, grid_pix_to_norm)def test_create_meshgrid3d(device, dtype):diff --git a/test/utils/test_helpers.py b/test/utils/test_helpers.pyindex 353beca14..f44f2f5c5 100644--- a/test/utils/test_helpers.py+++ b/test/utils/test_helpers.py@@ -1,7 +1,7 @@import pytestimport torch-from torch.testing import assert_allclose+from kornia.testing import assert_closefrom kornia.utils import _extract_device_dtypefrom kornia.utils.helpers import _torch_histc_cast, _torch_inverse_cast, _torch_solve_cast, _torch_svd_cast@@ -67,13 +67,13 @@ class TestInverseCast:y = _torch_inverse_cast(x)- assert_allclose(y, y_expected)+ assert_close(y, y_expected)def test_jit(self, device, dtype):x = torch.rand(1, 3, 4, 4, device=device, dtype=dtype)op = _torch_inverse_castop_jit = torch.jit.script(op)- assert_allclose(op(x), op_jit(x))+ assert_close(op(x), op_jit(x))class TestHistcCast:@@ -83,7 +83,7 @@ class TestHistcCast:y = _torch_histc_cast(x, bins=4, min=0, max=3)- assert_allclose(y, y_expected)+ assert_close(y, y_expected)class TestSvdCast:@@ -92,7 +92,7 @@ class TestSvdCast:u, s, v = _torch_svd_cast(a)tol_val: float = 1e-1 if dtype == torch.float16 else 1e-3- assert_allclose(a, u @ torch.diag_embed(s) @ v.transpose(-2, -1), atol=tol_val, rtol=tol_val)+ assert_close(a, u @ torch.diag_embed(s) @ v.transpose(-2, -1), atol=tol_val, rtol=tol_val)class TestSolveCast:@@ -104,4 +104,4 @@ class TestSolveCast:error = torch.dist(B, A.matmul(X))tol_val: float = 1e-1 if dtype == torch.float16 else 1e-4- assert_allclose(error, torch.zeros_like(error), atol=tol_val, rtol=tol_val)+ assert_close(error, torch.zeros_like(error), atol=tol_val, rtol=tol_val)diff --git a/test/utils/test_image.py b/test/utils/test_image.pyindex 6fe97926c..9a1d64795 100644--- a/test/utils/test_image.py+++ b/test/utils/test_image.py@@ -1,9 +1,9 @@import numpy as npimport pytestimport torch-from torch.testing import assert_allcloseimport kornia+from kornia.testing import assert_close@pytest.mark.parametrize(@@ -51,7 +51,7 @@ def test_image_to_tensor(input_shape, expected):assert isinstance(tensor, torch.Tensor)to_tensor = kornia.utils.ImageToTensor(keepdim=False)- assert_allclose(tensor, to_tensor(image))+ assert_close(tensor, to_tensor(image))@pytest.mark.parametrize(diff --git a/test/utils/test_metrics.py b/test/utils/test_metrics.pyindex 34bcaeb92..b5cfdd9a5 100644--- a/test/utils/test_metrics.py+++ b/test/utils/test_metrics.py@@ -1,7 +1,7 @@import torch-from torch.testing import assert_allcloseimport kornia+from kornia.testing import assert_closeclass TestMeanIoU:@@ -14,7 +14,7 @@ class TestMeanIoU:mean_iou = kornia.utils.metrics.mean_iou(predicted, actual, num_classes)mean_iou_real = torch.tensor([[1.0, 1.0]], dtype=torch.float32)assert mean_iou.shape == (batch_size, num_classes)- assert_allclose(mean_iou, mean_iou_real)+ assert_close(mean_iou, mean_iou_real)def test_two_classes_perfect_batch2(self):batch_size = 2@@ -25,7 +25,7 @@ class TestMeanIoU:mean_iou = kornia.utils.metrics.mean_iou(predicted, actual, num_classes)mean_iou_real = torch.tensor([[1.0, 1.0], [1.0, 1.0]], dtype=torch.float32)assert mean_iou.shape == (batch_size, num_classes)- assert_allclose(mean_iou, mean_iou_real)+ assert_close(mean_iou, mean_iou_real)def test_two_classes(self):batch_size = 1@@ -37,7 +37,7 @@ class TestMeanIoU:mean_iou = kornia.utils.metrics.mean_iou(predicted, actual, num_classes)mean_iou_real = torch.tensor([[0.75, 0.80]], dtype=torch.float32)assert mean_iou.shape == (batch_size, num_classes)- assert_allclose(mean_iou, mean_iou_real)+ assert_close(mean_iou, mean_iou_real)def test_four_classes_2d_perfect(self):batch_size = 1@@ -48,7 +48,7 @@ class TestMeanIoU:mean_iou = kornia.utils.metrics.mean_iou(predicted, actual, num_classes)mean_iou_real = torch.tensor([[1.0, 1.0, 1.0, 1.0]], dtype=torch.float32)assert mean_iou.shape == (batch_size, num_classes)- assert_allclose(mean_iou, mean_iou_real)+ assert_close(mean_iou, mean_iou_real)def test_four_classes_one_missing(self):batch_size = 1@@ -59,7 +59,7 @@ class TestMeanIoU:mean_iou = kornia.utils.metrics.mean_iou(predicted, actual, num_classes)mean_iou_real = torch.tensor([[0.0, 1.0, 0.5, 0.5]], dtype=torch.float32)assert mean_iou.shape == (batch_size, num_classes)- assert_allclose(mean_iou, mean_iou_real)+ assert_close(mean_iou, mean_iou_real)class TestConfusionMatrix:@@ -70,7 +70,7 @@ class TestConfusionMatrix:conf_mat = kornia.utils.metrics.confusion_matrix(predicted, actual, num_classes)conf_mat_real = torch.tensor([[[3, 1], [0, 4]]], dtype=torch.float32)- assert_allclose(conf_mat, conf_mat_real)+ assert_close(conf_mat, conf_mat_real)def test_two_classes_batch2(self):batch_size = 2@@ -80,7 +80,7 @@ class TestConfusionMatrix:conf_mat = kornia.utils.metrics.confusion_matrix(predicted, actual, num_classes)conf_mat_real = torch.tensor([[[3, 1], [0, 4]], [[3, 1], [0, 4]]], dtype=torch.float32)- assert_allclose(conf_mat, conf_mat_real)+ assert_close(conf_mat, conf_mat_real)def test_three_classes(self):num_classes = 3@@ -89,7 +89,7 @@ class TestConfusionMatrix:conf_mat = kornia.utils.metrics.confusion_matrix(predicted, actual, num_classes)conf_mat_real = torch.tensor([[[4, 1, 2], [3, 0, 2], [1, 2, 1]]], dtype=torch.float32)- assert_allclose(conf_mat, conf_mat_real)+ assert_close(conf_mat, conf_mat_real)def test_four_classes_one_missing(self):num_classes = 4@@ -98,7 +98,7 @@ class TestConfusionMatrix:conf_mat = kornia.utils.metrics.confusion_matrix(predicted, actual, num_classes)conf_mat_real = torch.tensor([[[0, 0, 0, 0], [0, 4, 1, 2], [0, 3, 0, 2], [0, 1, 2, 1]]], dtype=torch.float32)- assert_allclose(conf_mat, conf_mat_real)+ assert_close(conf_mat, conf_mat_real)def test_three_classes_normalized(self):num_classes = 3@@ -111,7 +111,7 @@ class TestConfusionMatrix:conf_mat_real = torch.tensor([[[0.5000, 0.3333, 0.4000], [0.3750, 0.0000, 0.4000], [0.1250, 0.6667, 0.2000]]], dtype=torch.float32)- assert_allclose(conf_mat, conf_mat_real)+ assert_close(conf_mat, conf_mat_real)def test_four_classes_2d_perfect(self):num_classes = 4@@ -120,7 +120,7 @@ class TestConfusionMatrix:conf_mat = kornia.utils.metrics.confusion_matrix(predicted, actual, num_classes)conf_mat_real = torch.tensor([[[4, 0, 0, 0], [0, 4, 0, 0], [0, 0, 4, 0], [0, 0, 0, 4]]], dtype=torch.float32)- assert_allclose(conf_mat, conf_mat_real)+ assert_close(conf_mat, conf_mat_real)def test_four_classes_2d_one_class_nonperfect(self):num_classes = 4@@ -129,7 +129,7 @@ class TestConfusionMatrix:conf_mat = kornia.utils.metrics.confusion_matrix(predicted, actual, num_classes)conf_mat_real = torch.tensor([[[3, 0, 0, 1], [1, 3, 0, 0], [0, 0, 4, 0], [0, 1, 0, 3]]], dtype=torch.float32)- assert_allclose(conf_mat, conf_mat_real)+ assert_close(conf_mat, conf_mat_real)def test_four_classes_2d_one_class_missing(self):num_classes = 4@@ -138,7 +138,7 @@ class TestConfusionMatrix:conf_mat = kornia.utils.metrics.confusion_matrix(predicted, actual, num_classes)conf_mat_real = torch.tensor([[[0, 0, 0, 4], [0, 4, 0, 0], [0, 0, 4, 0], [0, 0, 0, 4]]], dtype=torch.float32)- assert_allclose(conf_mat, conf_mat_real)+ assert_close(conf_mat, conf_mat_real)def test_four_classes_2d_one_class_no_predicted(self):num_classes = 4@@ -147,4 +147,4 @@ class TestConfusionMatrix:conf_mat = kornia.utils.metrics.confusion_matrix(predicted, actual, num_classes)conf_mat_real = torch.tensor([[[0, 0, 4, 4], [0, 0, 0, 0], [0, 0, 4, 0], [0, 0, 0, 4]]], dtype=torch.float32)- assert_allclose(conf_mat, conf_mat_real)+ assert_close(conf_mat, conf_mat_real)diff --git a/test/utils/test_pointcloud_io.py b/test/utils/test_pointcloud_io.pyindex 8ef7ce44f..e77e963f3 100644--- a/test/utils/test_pointcloud_io.py+++ b/test/utils/test_pointcloud_io.py@@ -1,9 +1,9 @@import osimport torch-from torch.testing import assert_allcloseimport kornia+from kornia.testing import assert_closeclass TestSaveLoadPointCloud:@@ -17,7 +17,7 @@ class TestSaveLoadPointCloud:# load filexyz_load = kornia.load_pointcloud_ply(filename)- assert_allclose(xyz_save.reshape(-1, 3), xyz_load)+ assert_close(xyz_save.reshape(-1, 3), xyz_load)# remove the temporal fileif os.path.exists(filename):