Skip to content

Commit

Permalink
test tolerance loosenings
Browse files Browse the repository at this point in the history
Summary: Increase some test tolerances so that they pass in more situations, and re-enable two tests.

Reviewed By: nikhilaravi

Differential Revision: D31379717

fbshipit-source-id: 06a25470cc7b6d71cd639d9fd7df500d4b84c079
  • Loading branch information
bottler authored and facebook-github-bot committed Oct 7, 2021
1 parent 8fa438c commit b26f4bc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
5 changes: 2 additions & 3 deletions tests/test_cameras_alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def test_corresponding_cameras_alignment(self):
"""
Checks the corresponding_cameras_alignment function.
"""
self.skipTest("Temporarily disabled pending investigation")
device = torch.device("cuda:0")

# try few different random setups
Expand Down Expand Up @@ -134,10 +133,10 @@ def _rmse(a):
)
elif mode == "extrinsics":
angle_err = so3_relative_angle(
cameras_aligned.R, cameras_tgt.R
cameras_aligned.R, cameras_tgt.R, cos_angle=True
).mean()
self.assertClose(
angle_err, torch.zeros_like(angle_err), atol=add_noise * 10.0
angle_err, torch.ones_like(angle_err), atol=add_noise * 0.03
)
self.assertNormsClose(
cameras_aligned.T, cameras_tgt.T, _rmse, atol=add_noise * 7.0
Expand Down
13 changes: 8 additions & 5 deletions tests/test_points_alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,13 @@ def test_init_transformation(self, batch_size=10):
self.assertClose(s_init, s, atol=atol)
self.assertClose(Xt_init, Xt, atol=atol)

def test_heterogeneous_inputs(self, batch_size=10):
def test_heterogeneous_inputs(self, batch_size=7):
"""
Tests whether we get the same result when running ICP on
a set of randomly-sized Pointclouds and on their padded versions.
"""

torch.manual_seed(4)
device = torch.device("cuda:0")

for estimate_scale in (True, False):
Expand Down Expand Up @@ -501,7 +502,6 @@ def test_corresponding_points_alignment(self, batch_size=10):
- use_pointclouds ... If True, passes the Pointclouds objects
to corresponding_points_alignment.
"""
self.skipTest("Temporarily disabled pending investigation")
# run this for several different point cloud sizes
for n_points in (100, 3, 2, 1):
# run this for several different dimensionalities
Expand Down Expand Up @@ -640,7 +640,10 @@ def align_and_get_mse(weights_):
if reflect and not allow_reflection:
# check that all rotations have det=1
self._assert_all_close(
torch.det(R_est), R_est.new_ones(batch_size), assert_error_message
torch.det(R_est),
R_est.new_ones(batch_size),
assert_error_message,
atol=2e-5,
)

else:
Expand All @@ -665,13 +668,13 @@ def align_and_get_mse(weights_):
desired_det = R_est.new_ones(batch_size)
if reflect:
desired_det *= -1.0
self._assert_all_close(torch.det(R_est), desired_det, msg, w)
self._assert_all_close(torch.det(R_est), desired_det, msg, w, atol=2e-5)

# check that the transformed point cloud
# X matches X_t
X_t_est = _apply_pcl_transformation(X, R_est, T_est, s=s_est)
self._assert_all_close(
X_t, X_t_est, assert_error_message, w[:, None, None], atol=1e-5
X_t, X_t_est, assert_error_message, w[:, None, None], atol=2e-5
)

def _assert_all_close(self, a_, b_, err_message, weights=None, atol=1e-6):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_rasterize_rectangle_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def _compare_square_with_nonsq(

# Finally check the gradients of the input vertices for
# the square and non square case
self.assertClose(verts_square.grad, grad_tensor.grad, rtol=3e-4)
self.assertClose(verts_square.grad, grad_tensor.grad, rtol=3e-4, atol=5e-3)

def test_gpu(self):
"""
Expand Down

0 comments on commit b26f4bc

Please sign in to comment.