π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
fix lint tests for test files
edgarriba538de801bf48
diff --git a/test/test_conversions.py b/test/test_conversions.pyindex 6200689e4..fba1805c6 100644--- a/test/test_conversions.py+++ b/test/test_conversions.py@@ -48,23 +48,24 @@ class Tester(unittest.TestCase):res = gradcheck(tgm.rtvec_to_pose, (rtvec,), raise_exception=True)self.assertTrue(res)-def test_rotation_matrix_to_angle_axis(self):rmat_1 = torch.tensor([[-0.30382753, -0.95095137, -0.05814062, 0.],- [-0.71581715, 0.26812278, -0.64476041, 0.],- [ 0.62872461, -0.15427791, -0.76217038, 0.],- [ 0. , 0. , 0. , 1.]])- rvec_1 = torch.tensor([1.50485376, -2.10737739, 0.7214174 ])+ [-0.71581715, 0.26812278, -0.64476041, 0.],+ [0.62872461, -0.15427791, -0.76217038, 0.],+ [0., 0., 0., 1.]])+ rvec_1 = torch.tensor([1.50485376, -2.10737739, 0.7214174])- rmat_2 = torch.tensor([[ 0.6027768, -0.79275544, -0.09054801, 0.],- [-0.67915707, -0.56931658, 0.46327563, 0.],+ rmat_2 = torch.tensor([[0.6027768, -0.79275544, -0.09054801, 0.],+ [-0.67915707, -0.56931658, 0.46327563, 0.],[-0.41881476, -0.21775548, -0.88157628, 0.],- [ 0. , 0. , 0. , 1.]])- rvec_2 = torch.tensor([-2.44916812, 1.18053411 , 0.4085298 ])+ [0., 0., 0., 1.]])+ rvec_2 = torch.tensor([-2.44916812, 1.18053411, 0.4085298])rmat = torch.stack([rmat_2, rmat_1], dim=0)rvec = torch.stack([rvec_2, rvec_1], dim=0)- self.assertTrue(check_equal_torch(tgm.rotation_matrix_to_angle_axis(rmat), rvec))-+ self.assertTrue(+ check_equal_torch(+ tgm.rotation_matrix_to_angle_axis(rmat),+ rvec))def test_rotation_matrix_to_angle_axis_gradcheck(self):# generate input data@@ -73,14 +74,10 @@ class Tester(unittest.TestCase):rmat = utils.tensor_to_gradcheck_var(rmat) # to var# evaluate function gradient- res = gradcheck(tgm.rotation_matrix_to_angle_axis, (rmat,), raise_exception=True)+ res = gradcheck(tgm.rotation_matrix_to_angle_axis,+ (rmat,), raise_exception=True)self.assertTrue(res)- @unittest.skip('')- def test_rotation_matrix_to_angle_axis_gradcheck(self):- print('test_rotation_matrix_to_angle_axis_gradcheck to be implemented :)') # noqa- self.assertTrue(True)-if __name__ == '__main__':unittest.main()diff --git a/test/test_depth_warper.py b/test/test_depth_warper.pyindex d2def0480..7f42fc0d0 100644--- a/test/test_depth_warper.py+++ b/test/test_depth_warper.py@@ -63,7 +63,7 @@ class Tester(unittest.TestCase):# test functionalpatch_ref_functional = tgm.depth_warp(pinhole_i, pinhole_ref,- inv_depth_ref, patch_i)+ inv_depth_ref, patch_i)res = utils.check_equal_torch(patch_ref, patch_ref_functional)self.assertTrue(res)diff --git a/test/test_functional.py b/test/test_functional.pyindex 7dc7ef5b8..90d4e3afd 100644--- a/test/test_functional.py+++ b/test/test_functional.py@@ -109,8 +109,12 @@ class Tester(unittest.TestCase):self.assertAlmostEqual(error.item(), 0.0, places=4)# functional- self.assertTrue(torch.allclose(points_dst,- tgm.TransformPoints()(dst_homo_src, points_src)))+ self.assertTrue(+ torch.allclose(+ points_dst,+ tgm.TransformPoints()(+ dst_homo_src,+ points_src)))def test_transform_points_gradcheck(self):# generate input datadiff --git a/test/test_homography_warper.py b/test/test_homography_warper.pyindex f6f1a9968..024b2824c 100644--- a/test/test_homography_warper.py+++ b/test/test_homography_warper.py@@ -50,7 +50,7 @@ class Tester(unittest.TestCase):patch_dst_to_src_functional = tgm.homography_warp(patch_dst, tgm.inverse(dst_homo_src_i), (height, width))res = utils.check_equal_torch(patch_dst_to_src,- patch_dst_to_src_functional)+ patch_dst_to_src_functional)self.assertTrue(res)def test_homography_warper_gradcheck(self):@@ -79,8 +79,13 @@ class Tester(unittest.TestCase):self.assertTrue(res)# evaluate function gradient- res = gradcheck(tgm.homography_warp, (patch_src, dst_homo_src,- (height, width)), raise_exception=True)+ res = gradcheck(+ tgm.homography_warp,+ (patch_src,+ dst_homo_src,+ (height,+ width)),+ raise_exception=True)self.assertTrue(res)if __name__ == '__main__':diff --git a/torchgeometry/conversions.py b/torchgeometry/conversions.pyindex 9a9b60545..cc1de0ba5 100644--- a/torchgeometry/conversions.py+++ b/torchgeometry/conversions.py@@ -258,7 +258,7 @@ def rotation_matrix_to_quaternion(rotation_matrix, eps=1e-6):Return:Tensor: the rotation in quaternion-+"""rmat_t = torch.transpose(rotation_matrix, 1, 2)@@ -309,7 +309,7 @@ def rotation_matrix_to_quaternion(rotation_matrix, eps=1e-6):def quaternion_to_angle_axis(quaternion, eps=1e-6):"""Convert quaternion vector to angle axis of rotation-+Adapted from ceres C++ library: ceres-solver/include/ceres/rotation.hArgs: