Skip to content

Commit

Permalink
add run_if_labs tests.decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
fantaosha committed Jan 12, 2023
1 parent 724950f commit f0f12de
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/labs/lie_functional/test_se3.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

import torch

from tests.decorators import run_if_labs


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_exp(batch_size: int, dtype: torch.dtype):
Expand All @@ -22,6 +25,7 @@ def test_exp(batch_size: int, dtype: torch.dtype):
check_lie_group_function(se3, "exp", 1e-6, (tangent_vector,))


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_log(batch_size: int, dtype: torch.dtype):
Expand All @@ -35,6 +39,7 @@ def test_log(batch_size: int, dtype: torch.dtype):
check_lie_group_function(se3, "log", EPS, (group,), (left_project,))


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_adjoint(batch_size: int, dtype: torch.dtype):
Expand All @@ -46,6 +51,7 @@ def test_adjoint(batch_size: int, dtype: torch.dtype):
check_lie_group_function(se3, "adjoint", TEST_EPS, (group,))


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_inverse(batch_size: int, dtype: torch.dtype):
Expand All @@ -57,6 +63,7 @@ def test_inverse(batch_size: int, dtype: torch.dtype):
check_lie_group_function(se3, "inverse", TEST_EPS, (group,))


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_hat(batch_size: int, dtype: torch.dtype):
Expand All @@ -68,6 +75,7 @@ def test_hat(batch_size: int, dtype: torch.dtype):
check_lie_group_function(se3, "hat", TEST_EPS, (tangent_vector,))


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_vee(batch_size: int, dtype: torch.dtype):
Expand All @@ -84,6 +92,7 @@ def test_vee(batch_size: int, dtype: torch.dtype):
assert torch.allclose(actual_tangent_vector, tangent_vector, atol=TEST_EPS)


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_compose(batch_size: int, dtype: torch.dtype):
Expand All @@ -96,6 +105,7 @@ def test_compose(batch_size: int, dtype: torch.dtype):
check_lie_group_function(se3, "compose", TEST_EPS, (group0, group1))


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_lift(batch_size: int, dtype: torch.dtype):
Expand All @@ -112,6 +122,7 @@ def test_lift(batch_size: int, dtype: torch.dtype):
check_lie_group_function(se3, "lift", TEST_EPS, (matrix,))


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_project(batch_size: int, dtype: torch.dtype):
Expand All @@ -129,6 +140,7 @@ def test_project(batch_size: int, dtype: torch.dtype):
check_lie_group_function(se3, "project", TEST_EPS, (matrix,))


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_left_act(batch_size: int, dtype: torch.dtype):
Expand Down Expand Up @@ -159,6 +171,7 @@ def test_left_act(batch_size: int, dtype: torch.dtype):
check_lie_group_function(se3, "left_act", TEST_EPS, (group, matrix))


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_left_project(batch_size: int, dtype: torch.dtype):
Expand Down
7 changes: 7 additions & 0 deletions tests/labs/lie_functional/test_so3.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def test_exp(batch_size: int, dtype: torch.dtype):
check_lie_group_function(so3, "exp", 1e-6, (tangent_vector,))


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_log(batch_size: int, dtype: torch.dtype):
Expand Down Expand Up @@ -101,6 +102,7 @@ def test_vee(batch_size: int, dtype: torch.dtype):
assert torch.allclose(actual_tangent_vector, tangent_vector, atol=TEST_EPS)


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_compose(batch_size: int, dtype: torch.dtype):
Expand All @@ -113,6 +115,7 @@ def test_compose(batch_size: int, dtype: torch.dtype):
check_lie_group_function(so3, "compose", TEST_EPS, (group0, group1))


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_quaternion_to_rotation(batch_size: int, dtype: torch.dtype):
Expand All @@ -125,6 +128,7 @@ def test_quaternion_to_rotation(batch_size: int, dtype: torch.dtype):
check_lie_group_function(so3, "quaternion_to_rotation", TEST_EPS, (quaternion,))


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_lift(batch_size: int, dtype: torch.dtype):
Expand All @@ -141,6 +145,7 @@ def test_lift(batch_size: int, dtype: torch.dtype):
check_lie_group_function(so3, "lift", TEST_EPS, (matrix,))


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_project(batch_size: int, dtype: torch.dtype):
Expand All @@ -158,6 +163,7 @@ def test_project(batch_size: int, dtype: torch.dtype):
check_lie_group_function(so3, "project", TEST_EPS, (matrix,))


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_left_act(batch_size: int, dtype: torch.dtype):
Expand Down Expand Up @@ -188,6 +194,7 @@ def test_left_act(batch_size: int, dtype: torch.dtype):
check_lie_group_function(so3, "left_act", TEST_EPS, (group, matrix))


@run_if_labs()
@pytest.mark.parametrize("batch_size", [1, 20, 100])
@pytest.mark.parametrize("dtype", [torch.float32, torch.float64])
def test_left_project(batch_size: int, dtype: torch.dtype):
Expand Down

0 comments on commit f0f12de

Please sign in to comment.