From d37fa4e8df737f2f28635041ea10c8d94d78c3e8 Mon Sep 17 00:00:00 2001 From: Michael Eickenberg Date: Fri, 20 Oct 2023 11:07:49 -0400 Subject: [PATCH 1/6] TST contracted t1 forward tests --- tests/test_t1_forward.py | 146 ++++++++++++++++++++++++--------------- 1 file changed, 90 insertions(+), 56 deletions(-) diff --git a/tests/test_t1_forward.py b/tests/test_t1_forward.py index 9299b9f..84c79ee 100644 --- a/tests/test_t1_forward.py +++ b/tests/test_t1_forward.py @@ -39,77 +39,111 @@ def check_t1_forward(N: int, dim: int, device: str) -> None: assert l_1_error < 1e-5 * N**4.5 -#### 1D TESTS #### - -Ns = [ - 5, - 10, - 15, - 100, - 101, - 1000, - 1001, - 3750, - 5000, - 5001, - 6250, - 7500, +Ns_and_dims = [ + (2, 1), + (3, 1), + (5, 1), + (10, 1), + (100, 1), + (101, 1), + (1000, 1), + (10001, 1), + (2, 2), + (3, 2), + (5, 2), + (10, 2), + (101, 2), + (2, 3), + (3, 3), + (5, 3), + (10, 3), + (37, 3), ] -@pytest.mark.parametrize("N", Ns) -def test_t1_1D_forward_CPU(N: int) -> None: - check_t1_forward(N, 1, "cpu") +@pytest.mark.parametrize("N_and_dim", Ns_and_dims) +def test_t1_forward_CPU(N_and_dim) -> None: + N, dim = N_and_dim + check_t1_forward(N, dim, "cpu") -@pytest.mark.parametrize("N", Ns) -def test_t1_1D_forward_cuda(N: int) -> None: - check_t1_forward(N, 1, "cuda") +@pytest.mark.parametrize("N_and_dim", Ns_and_dims) +def test_t1_forward_cuda(N_and_dim) -> None: + N, dim = N_and_dim + check_t1_forward(N, dim, "cuda") -#### 2D TESTS #### -Ns = [ - 3, - 10, - 15, - 75, - 76, - 95, - 96, - 100, - 101, -] +# #### 1D TESTS #### +# Ns = [ +# 5, +# 10, +# 15, +# 100, +# 101, +# 1000, +# 1001, +# 3750, +# 5000, +# 5001, +# 6250, +# 7500, +# ] -@pytest.mark.parametrize("N", Ns) -def test_t1_2D_forward_CPU(N: int) -> None: - check_t1_forward(N, 2, "cpu") +# @pytest.mark.parametrize("N", Ns) +# def test_t1_1D_forward_CPU(N: int) -> None: +# check_t1_forward(N, 1, "cpu") -@pytest.mark.parametrize("N", Ns) -def test_t1_2D_forward_cuda(N: int) -> None: - check_t1_forward(N, 2, "cuda") +# @pytest.mark.parametrize("N", Ns) +# def test_t1_1D_forward_cuda(N: int) -> None: +# check_t1_forward(N, 1, "cuda") -#### 3D TESTS #### -Ns = [ - 3, - 5, - 10, - 15, - 16, - 25, - 26, - 37, -] +# #### 2D TESTS #### +# Ns = [ +# 3, +# 10, +# 15, +# 75, +# 76, +# 95, +# 96, +# 100, +# 101, +# ] + + +# @pytest.mark.parametrize("N", Ns) +# def test_t1_2D_forward_CPU(N: int) -> None: +# check_t1_forward(N, 2, "cpu") + + +# @pytest.mark.parametrize("N", Ns) +# def test_t1_2D_forward_cuda(N: int) -> None: +# check_t1_forward(N, 2, "cuda") + + +# #### 3D TESTS #### + +# Ns = [ +# 3, +# 5, +# 10, +# 15, +# 16, +# 25, +# 26, +# 37, +# ] -@pytest.mark.parametrize("N", Ns) -def test_t1_3D_forward_CPU(N: int) -> None: - check_t1_forward(N, 3, "cpu") +# @pytest.mark.parametrize("N", Ns) +# def test_t1_3D_forward_CPU(N: int) -> None: +# check_t1_forward(N, 3, "cpu") -@pytest.mark.parametrize("N", Ns) -def test_t1_3D_forward_cuda(N: int) -> None: - check_t1_forward(N, 3, "cuda") +# @pytest.mark.parametrize("N", Ns) +# def test_t1_3D_forward_cuda(N: int) -> None: +# check_t1_forward(N, 3, "cuda") From 01712efa72353cc7eb2a77f7bd8e1f954e6c3bc6 Mon Sep 17 00:00:00 2001 From: Michael Eickenberg Date: Fri, 20 Oct 2023 11:24:36 -0400 Subject: [PATCH 2/6] TST contracted type 2 forward tests --- tests/test_t2_forward.py | 148 ++++++++++++++++++++++++--------------- 1 file changed, 91 insertions(+), 57 deletions(-) diff --git a/tests/test_t2_forward.py b/tests/test_t2_forward.py index ed8e692..c62da96 100644 --- a/tests/test_t2_forward.py +++ b/tests/test_t2_forward.py @@ -38,78 +38,112 @@ def check_t2_forward(N: int, dim: int, device: str, fftshift=False) -> None: assert l_1_error < 1.2e-4 * N**3.2 -#### 1D TESTS #### - -Ns = [ - 5, - 10, - 15, - 100, - 101, - 1000, - 1001, - 3750, - 5000, - 5001, - 6250, - 7500, +Ns_and_dims = [ + (2, 1), + (3, 1), + (5, 1), + (10, 1), + (100, 1), + (101, 1), + (1000, 1), + (10001, 1), + (2, 2), + (3, 2), + (5, 2), + (10, 2), + (101, 2), + (2, 3), + (3, 3), + (5, 3), + (10, 3), + (37, 3), ] -@pytest.mark.parametrize("N", Ns) -def test_t2_1D_forward_CPU(N: int) -> None: - check_t2_forward(N, 1, "cpu") +@pytest.mark.parametrize("N_and_dim", Ns_and_dims) +def test_t2_forward_CPU(N_and_dim) -> None: + N, dim = N_and_dim + check_t2_forward(N, dim, "cpu") -@pytest.mark.parametrize("N", Ns) -def test_t2_1D_forward_cuda(N: int) -> None: - check_t2_forward(N, 1, "cuda") +@pytest.mark.parametrize("N_and_dim", Ns_and_dims) +def test_t2_forward_cuda(N_and_dim) -> None: + N, dim = N_and_dim + check_t2_forward(N, dim, "cuda") -#### 2D TESTS #### -Ns = [ - 3, - 10, - 15, - 75, - 76, - 95, - 96, - 100, - 101, -] +# #### 1D TESTS #### +# Ns = [ +# 5, +# 10, +# 15, +# 100, +# 101, +# 1000, +# 1001, +# 3750, +# 5000, +# 5001, +# 6250, +# 7500, +# ] -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("fftshift", [False, True]) -def test_t2_2D_forward_CPU(N: int, fftshift: bool) -> None: - check_t2_forward(N, 2, "cpu", fftshift) +# @pytest.mark.parametrize("N", Ns) +# def test_t2_1D_forward_CPU(N: int) -> None: +# check_t2_forward(N, 1, "cpu") -@pytest.mark.parametrize("N", Ns) -def test_t2_2D_forward_cuda(N: int) -> None: - check_t2_forward(N, 2, "cuda") +# @pytest.mark.parametrize("N", Ns) +# def test_t2_1D_forward_cuda(N: int) -> None: +# check_t2_forward(N, 1, "cuda") -#### 3D TESTS #### -Ns = [ - 3, - 5, - 10, - 15, - 16, - 25, - 26, - 37, -] +# #### 2D TESTS #### +# Ns = [ +# 3, +# 10, +# 15, +# 75, +# 76, +# 95, +# 96, +# 100, +# 101, +# ] + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("fftshift", [False, True]) +# def test_t2_2D_forward_CPU(N: int, fftshift: bool) -> None: +# check_t2_forward(N, 2, "cpu", fftshift) + + +# @pytest.mark.parametrize("N", Ns) +# def test_t2_2D_forward_cuda(N: int) -> None: +# check_t2_forward(N, 2, "cuda") + + +# #### 3D TESTS #### + +# Ns = [ +# 3, +# 5, +# 10, +# 15, +# 16, +# 25, +# 26, +# 37, +# ] -@pytest.mark.parametrize("N", Ns) -def test_t2_3D_forward_CPU(N: int) -> None: - check_t2_forward(N, 3, "cpu") +# @pytest.mark.parametrize("N", Ns) +# def test_t2_3D_forward_CPU(N: int) -> None: +# check_t2_forward(N, 3, "cpu") -@pytest.mark.parametrize("N", Ns) -def test_t2_3D_forward_cuda(N: int) -> None: - check_t2_forward(N, 3, "cuda") +# @pytest.mark.parametrize("N", Ns) +# def test_t2_3D_forward_cuda(N: int) -> None: +# check_t2_forward(N, 3, "cuda") From 41f73bd7c70917b7a6d4976c1b0453e769aeb93f Mon Sep 17 00:00:00 2001 From: Michael Eickenberg Date: Fri, 20 Oct 2023 15:34:47 -0400 Subject: [PATCH 3/6] TST condense backward tests --- tests/test_t1_backward.py | 369 ++++++++++++++++++++------------------ tests/test_t2_backward.py | 362 ++++++++++++++++++++----------------- 2 files changed, 395 insertions(+), 336 deletions(-) diff --git a/tests/test_t1_backward.py b/tests/test_t1_backward.py index 82dcbe4..f2637c8 100644 --- a/tests/test_t1_backward.py +++ b/tests/test_t1_backward.py @@ -41,182 +41,211 @@ def func(points, values): isign=isign, ) - assert gradcheck(func, inputs, eps=1e-8, atol=1e-5 * N) - - -#### 1D TESTS #### -Ns = [ - 5, - 8, - 10, - 15, - 16, - 63, - 100, - 101, + assert gradcheck(func, inputs, eps=1e-8, atol=2e-4 * N) + + +shapes_and_Ns = [ + (2, 2), + (2, 51), + (5, 4), + (6, 50), + (101, 10), + ((2,), 10), + ((5,), 25), + ((2, 2), 21), + ((20, 21), 51), + ((8, 30), 23), + ((5, 4, 3), 10), ] -length_modifiers = [-1, 0, 1, 4] - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t1_1D_backward_CPU_values( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t1_backward(N, N + modifier, fftshift, isign, "cpu", False) - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t1_1D_backward_CPU_points( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t1_backward(N, N + modifier, fftshift, isign, "cpu", True) - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t1_1D_backward_cuda_values( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t1_backward(N, N + modifier, fftshift, isign, "cuda", False) - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t1_1D_backward_cuda_points( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t1_backward(N, N + modifier, fftshift, isign, "cuda", True) - - -#### 2D TESTS #### - - -Ns = [ - 3, - # 5, - # 8, - # 10, - # 15, - # 16, -] - -length_modifiers = [ - 0, - 1, - -1, -] - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t1_2D_backward_CPU_points( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t1_backward(N, (N, N + modifier), fftshift, isign, "cpu", True) - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) +@pytest.mark.parametrize("output_shape, N", shapes_and_Ns) @pytest.mark.parametrize("fftshift", [False, True]) @pytest.mark.parametrize("isign", [-1, 1]) -def test_t1_2D_backward_CPU_values( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t1_backward(N, (N, N + modifier), fftshift, isign, "cpu", False) - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t1_2D_backward_cuda_values( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t1_backward(N, (N, N + modifier), fftshift, isign, "cuda", False) - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t1_2D_backward_cuda_points( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t1_backward(N, (N, N + modifier), fftshift, isign, "cuda", True) - - -#### 3D TESTS #### - -Ns = [ - 3, - # 5, - # 8, -] - -length_modifiers = [ - # -1, - 0, - 1, - # 4 -] +def test_t1_backward_CPU_points(output_shape, N, fftshift, isign) -> None: + check_t1_backward(N, output_shape, fftshift, isign, "cpu", True) -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) +@pytest.mark.parametrize("output_shape, N", shapes_and_Ns) @pytest.mark.parametrize("fftshift", [False, True]) @pytest.mark.parametrize("isign", [-1, 1]) -def test_t1_3D_backward_CPU_values( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t1_backward( - N, (N, N + modifier, N + 2 * modifier), fftshift, isign, "cpu", False - ) - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t1_3D_backward_CPU_points( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t1_backward( - N, (N, N + modifier, N + 2 * modifier), fftshift, isign, "cpu", True - ) - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t1_3D_backward_cuda_values( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t1_backward( - N, (N, N + modifier, N + 2 * modifier), fftshift, isign, "cuda", False - ) - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t1_3D_backward_cuda_points( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t1_backward( - N, (N, N + modifier, N + 2 * modifier), fftshift, isign, "cuda", True - ) +def test_t1_backward_CPU_values(output_shape, N, fftshift, isign) -> None: + check_t1_backward(N, output_shape, fftshift, isign, "cpu", False) + + +# #### 1D TESTS #### +# Ns = [ +# 5, +# 8, +# 10, +# 15, +# 16, +# 63, +# 100, +# 101, +# ] + +# length_modifiers = [-1, 0, 1, 4] + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t1_1D_backward_CPU_values( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t1_backward(N, N + modifier, fftshift, isign, "cpu", False) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t1_1D_backward_CPU_points( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t1_backward(N, N + modifier, fftshift, isign, "cpu", True) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t1_1D_backward_cuda_values( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t1_backward(N, N + modifier, fftshift, isign, "cuda", False) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t1_1D_backward_cuda_points( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t1_backward(N, N + modifier, fftshift, isign, "cuda", True) + + +# #### 2D TESTS #### + + +# Ns = [ +# 3, +# # 5, +# # 8, +# # 10, +# # 15, +# # 16, +# ] + +# length_modifiers = [ +# 0, +# 1, +# -1, +# ] + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t1_2D_backward_CPU_points( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t1_backward(N, (N, N + modifier), fftshift, isign, "cpu", True) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t1_2D_backward_CPU_values( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t1_backward(N, (N, N + modifier), fftshift, isign, "cpu", False) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t1_2D_backward_cuda_values( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t1_backward(N, (N, N + modifier), fftshift, isign, "cuda", False) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t1_2D_backward_cuda_points( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t1_backward(N, (N, N + modifier), fftshift, isign, "cuda", True) + + +# #### 3D TESTS #### + +# Ns = [ +# 3, +# # 5, +# # 8, +# ] + +# length_modifiers = [ +# # -1, +# 0, +# 1, +# # 4 +# ] + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t1_3D_backward_CPU_values( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t1_backward( +# N, (N, N + modifier, N + 2 * modifier), fftshift, isign, "cpu", False +# ) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t1_3D_backward_CPU_points( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t1_backward( +# N, (N, N + modifier, N + 2 * modifier), fftshift, isign, "cpu", True +# ) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t1_3D_backward_cuda_values( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t1_backward( +# N, (N, N + modifier, N + 2 * modifier), fftshift, isign, "cuda", False +# ) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t1_3D_backward_cuda_points( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t1_backward( +# N, (N, N + modifier, N + 2 * modifier), fftshift, isign, "cuda", True +# ) diff --git a/tests/test_t2_backward.py b/tests/test_t2_backward.py index 63d3d6f..375d23b 100644 --- a/tests/test_t2_backward.py +++ b/tests/test_t2_backward.py @@ -13,16 +13,17 @@ def check_t2_backward( - N: int, - points_shape: Tuple[int, ...], + targets_shape: Tuple[int, ...], + n_points: int, fftshift: bool, isign: int, device: str, points_or_targets: bool, ) -> None: - dims = points_shape[0] + dims = len(targets_shape) + points_shape = (dims, n_points) points = torch.rand(points_shape, dtype=torch.float64).to(device) * 2 * np.pi - targets = torch.randn(tuple(np.repeat(N, dims)), dtype=torch.complex128).to(device) + targets = torch.randn(*targets_shape, dtype=torch.complex128).to(device) points.requires_grad = points_or_targets targets.requires_grad = not points_or_targets @@ -37,174 +38,203 @@ def func(points, targets): isign=isign, ) - assert gradcheck(func, inputs, eps=1e-8, atol=2e-5 * N) - - -#### 1D TESTS #### - -Ns = [ - 5, - 8, - 10, - 15, - 16, - 63, + assert gradcheck( + func, inputs, eps=1e-8, atol=3e-4 * np.prod(targets_shape) ** (1.0 / dims) + ) + + +shapes_and_Ns = [ + ((2,), 2), + ((2,), 51), + ((5,), 4), + ((6,), 50), + ((101,), 10), + ((2, 2), 21), + ((20, 21), 51), + ((8, 30), 23), + ((5, 4, 3), 10), ] -length_modifiers = [-1, 0, 1, 4] - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t2_1D_backward_CPU_targets( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t2_backward(N, (1, N + modifier), fftshift, isign, "cpu", False) - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) +@pytest.mark.parametrize("target_shape, N", shapes_and_Ns) @pytest.mark.parametrize("fftshift", [False, True]) @pytest.mark.parametrize("isign", [-1, 1]) -def test_t2_1D_backward_CPU_points( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t2_backward(N, (1, N + modifier), fftshift, isign, "cpu", True) +def test_t2_backward_CPU_points(target_shape, N, fftshift, isign) -> None: + check_t2_backward(target_shape, N, fftshift, isign, "cpu", True) -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) +@pytest.mark.parametrize("target_shape, N", shapes_and_Ns) @pytest.mark.parametrize("fftshift", [False, True]) @pytest.mark.parametrize("isign", [-1, 1]) -def test_t2_1D_backward_cuda_targets( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t2_backward(N, (1, N + modifier), fftshift, isign, "cuda", False) - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t2_1D_backward_cuda_points( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t2_backward(N, (1, N + modifier), fftshift, isign, "cuda", True) - - -#### 2D TESTS #### - -Ns = [ - 3, - # 5, - # 8, - # 10, - # 15, - # 16, -] - -length_modifiers = [ - 0, - 1, - # 4, - -1, -] - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t1_2D_backward_CPU_targets( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t2_backward(N, (2, N + modifier), fftshift, isign, "cpu", False) - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t1_2D_backward_CPU_points( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t2_backward(N, (2, N + modifier), fftshift, isign, "cpu", True) - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t1_2D_backward_cuda_targets( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t2_backward(N, (2, N + modifier), fftshift, isign, "cuda", False) - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t1_2D_backward_cuda_points( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t2_backward(N, (2, N + modifier), fftshift, isign, "cuda", True) - - -#### 3D TESTS #### - - -Ns = [ - 3, - # 5, - # 8, -] - -length_modifiers = [ - # -1, - 0, - 1, - # 4 -] - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t2_3D_backward_CPU_targets( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t2_backward(N, (3, N + modifier), fftshift, isign, "cpu", False) - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t2_3D_backward_CPU_points( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t2_backward(N, (3, N + modifier), fftshift, isign, "cpu", True) - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t2_3D_backward_cuda_targets( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t2_backward(N, (3, N + modifier), fftshift, isign, "cuda", False) - - -@pytest.mark.parametrize("N", Ns) -@pytest.mark.parametrize("modifier", length_modifiers) -@pytest.mark.parametrize("fftshift", [False, True]) -@pytest.mark.parametrize("isign", [-1, 1]) -def test_t2_3D_backward_cuda_points( - N: int, modifier: int, fftshift: bool, isign: int -) -> None: - check_t2_backward(N, (3, N + modifier), fftshift, isign, "cuda", True) +def test_t2_backward_CPU_values(target_shape, N, fftshift, isign) -> None: + check_t2_backward(target_shape, N, fftshift, isign, "cpu", False) + + +# #### 1D TESTS #### + +# Ns = [ +# 5, +# 8, +# 10, +# 15, +# 16, +# 63, +# ] + +# length_modifiers = [-1, 0, 1, 4] + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t2_1D_backward_CPU_targets( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t2_backward(N, (1, N + modifier), fftshift, isign, "cpu", False) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t2_1D_backward_CPU_points( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t2_backward(N, (1, N + modifier), fftshift, isign, "cpu", True) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t2_1D_backward_cuda_targets( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t2_backward(N, (1, N + modifier), fftshift, isign, "cuda", False) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t2_1D_backward_cuda_points( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t2_backward(N, (1, N + modifier), fftshift, isign, "cuda", True) + + +# #### 2D TESTS #### + +# Ns = [ +# 3, +# # 5, +# # 8, +# # 10, +# # 15, +# # 16, +# ] + +# length_modifiers = [ +# 0, +# 1, +# # 4, +# -1, +# ] + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t1_2D_backward_CPU_targets( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t2_backward(N, (2, N + modifier), fftshift, isign, "cpu", False) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t1_2D_backward_CPU_points( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t2_backward(N, (2, N + modifier), fftshift, isign, "cpu", True) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t1_2D_backward_cuda_targets( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t2_backward(N, (2, N + modifier), fftshift, isign, "cuda", False) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t1_2D_backward_cuda_points( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t2_backward(N, (2, N + modifier), fftshift, isign, "cuda", True) + + +# #### 3D TESTS #### + + +# Ns = [ +# 3, +# # 5, +# # 8, +# ] + +# length_modifiers = [ +# # -1, +# 0, +# 1, +# # 4 +# ] + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t2_3D_backward_CPU_targets( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t2_backward(N, (3, N + modifier), fftshift, isign, "cpu", False) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t2_3D_backward_CPU_points( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t2_backward(N, (3, N + modifier), fftshift, isign, "cpu", True) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t2_3D_backward_cuda_targets( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t2_backward(N, (3, N + modifier), fftshift, isign, "cuda", False) + + +# @pytest.mark.parametrize("N", Ns) +# @pytest.mark.parametrize("modifier", length_modifiers) +# @pytest.mark.parametrize("fftshift", [False, True]) +# @pytest.mark.parametrize("isign", [-1, 1]) +# def test_t2_3D_backward_cuda_points( +# N: int, modifier: int, fftshift: bool, isign: int +# ) -> None: +# check_t2_backward(N, (3, N + modifier), fftshift, isign, "cuda", True) From 9c25a1b3855254dc6fd0685267b2acb3c05cfc5d Mon Sep 17 00:00:00 2001 From: Michael Eickenberg Date: Mon, 23 Oct 2023 12:35:14 -0400 Subject: [PATCH 4/6] TST add cuda tests back --- tests/test_t1_backward.py | 14 ++++++++++++++ tests/test_t2_backward.py | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/tests/test_t1_backward.py b/tests/test_t1_backward.py index f2637c8..dbd6919 100644 --- a/tests/test_t1_backward.py +++ b/tests/test_t1_backward.py @@ -73,6 +73,20 @@ def test_t1_backward_CPU_values(output_shape, N, fftshift, isign) -> None: check_t1_backward(N, output_shape, fftshift, isign, "cpu", False) +@pytest.mark.parametrize("output_shape, N", shapes_and_Ns) +@pytest.mark.parametrize("fftshift", [False, True]) +@pytest.mark.parametrize("isign", [-1, 1]) +def test_t1_backward_cuda_points(output_shape, N, fftshift, isign) -> None: + check_t1_backward(N, output_shape, fftshift, isign, "cuda", True) + + +@pytest.mark.parametrize("output_shape, N", shapes_and_Ns) +@pytest.mark.parametrize("fftshift", [False, True]) +@pytest.mark.parametrize("isign", [-1, 1]) +def test_t1_backward_cuda_values(output_shape, N, fftshift, isign) -> None: + check_t1_backward(N, output_shape, fftshift, isign, "cuda", False) + + # #### 1D TESTS #### # Ns = [ # 5, diff --git a/tests/test_t2_backward.py b/tests/test_t2_backward.py index 375d23b..536cca4 100644 --- a/tests/test_t2_backward.py +++ b/tests/test_t2_backward.py @@ -70,6 +70,20 @@ def test_t2_backward_CPU_values(target_shape, N, fftshift, isign) -> None: check_t2_backward(target_shape, N, fftshift, isign, "cpu", False) +@pytest.mark.parametrize("target_shape, N", shapes_and_Ns) +@pytest.mark.parametrize("fftshift", [False, True]) +@pytest.mark.parametrize("isign", [-1, 1]) +def test_t2_backward_cuda_points(target_shape, N, fftshift, isign) -> None: + check_t2_backward(target_shape, N, fftshift, isign, "cuda", True) + + +@pytest.mark.parametrize("target_shape, N", shapes_and_Ns) +@pytest.mark.parametrize("fftshift", [False, True]) +@pytest.mark.parametrize("isign", [-1, 1]) +def test_t2_backward_cuda_values(target_shape, N, fftshift, isign) -> None: + check_t2_backward(target_shape, N, fftshift, isign, "cuda", False) + + # #### 1D TESTS #### # Ns = [ From 340dec814609e023251bbaac4a6c14bf02ae9cb3 Mon Sep 17 00:00:00 2001 From: Michael Eickenberg Date: Mon, 23 Oct 2023 12:37:49 -0400 Subject: [PATCH 5/6] COSM remove commented code --- tests/test_t1_backward.py | 178 -------------------------------------- tests/test_t1_forward.py | 76 ---------------- tests/test_t2_backward.py | 170 ------------------------------------ tests/test_t2_forward.py | 77 ----------------- 4 files changed, 501 deletions(-) diff --git a/tests/test_t1_backward.py b/tests/test_t1_backward.py index dbd6919..a426f81 100644 --- a/tests/test_t1_backward.py +++ b/tests/test_t1_backward.py @@ -85,181 +85,3 @@ def test_t1_backward_cuda_points(output_shape, N, fftshift, isign) -> None: @pytest.mark.parametrize("isign", [-1, 1]) def test_t1_backward_cuda_values(output_shape, N, fftshift, isign) -> None: check_t1_backward(N, output_shape, fftshift, isign, "cuda", False) - - -# #### 1D TESTS #### -# Ns = [ -# 5, -# 8, -# 10, -# 15, -# 16, -# 63, -# 100, -# 101, -# ] - -# length_modifiers = [-1, 0, 1, 4] - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t1_1D_backward_CPU_values( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t1_backward(N, N + modifier, fftshift, isign, "cpu", False) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t1_1D_backward_CPU_points( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t1_backward(N, N + modifier, fftshift, isign, "cpu", True) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t1_1D_backward_cuda_values( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t1_backward(N, N + modifier, fftshift, isign, "cuda", False) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t1_1D_backward_cuda_points( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t1_backward(N, N + modifier, fftshift, isign, "cuda", True) - - -# #### 2D TESTS #### - - -# Ns = [ -# 3, -# # 5, -# # 8, -# # 10, -# # 15, -# # 16, -# ] - -# length_modifiers = [ -# 0, -# 1, -# -1, -# ] - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t1_2D_backward_CPU_points( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t1_backward(N, (N, N + modifier), fftshift, isign, "cpu", True) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t1_2D_backward_CPU_values( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t1_backward(N, (N, N + modifier), fftshift, isign, "cpu", False) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t1_2D_backward_cuda_values( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t1_backward(N, (N, N + modifier), fftshift, isign, "cuda", False) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t1_2D_backward_cuda_points( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t1_backward(N, (N, N + modifier), fftshift, isign, "cuda", True) - - -# #### 3D TESTS #### - -# Ns = [ -# 3, -# # 5, -# # 8, -# ] - -# length_modifiers = [ -# # -1, -# 0, -# 1, -# # 4 -# ] - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t1_3D_backward_CPU_values( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t1_backward( -# N, (N, N + modifier, N + 2 * modifier), fftshift, isign, "cpu", False -# ) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t1_3D_backward_CPU_points( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t1_backward( -# N, (N, N + modifier, N + 2 * modifier), fftshift, isign, "cpu", True -# ) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t1_3D_backward_cuda_values( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t1_backward( -# N, (N, N + modifier, N + 2 * modifier), fftshift, isign, "cuda", False -# ) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t1_3D_backward_cuda_points( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t1_backward( -# N, (N, N + modifier, N + 2 * modifier), fftshift, isign, "cuda", True -# ) diff --git a/tests/test_t1_forward.py b/tests/test_t1_forward.py index 84c79ee..f5ca7a4 100644 --- a/tests/test_t1_forward.py +++ b/tests/test_t1_forward.py @@ -71,79 +71,3 @@ def test_t1_forward_CPU(N_and_dim) -> None: def test_t1_forward_cuda(N_and_dim) -> None: N, dim = N_and_dim check_t1_forward(N, dim, "cuda") - - -# #### 1D TESTS #### - -# Ns = [ -# 5, -# 10, -# 15, -# 100, -# 101, -# 1000, -# 1001, -# 3750, -# 5000, -# 5001, -# 6250, -# 7500, -# ] - - -# @pytest.mark.parametrize("N", Ns) -# def test_t1_1D_forward_CPU(N: int) -> None: -# check_t1_forward(N, 1, "cpu") - - -# @pytest.mark.parametrize("N", Ns) -# def test_t1_1D_forward_cuda(N: int) -> None: -# check_t1_forward(N, 1, "cuda") - - -# #### 2D TESTS #### -# Ns = [ -# 3, -# 10, -# 15, -# 75, -# 76, -# 95, -# 96, -# 100, -# 101, -# ] - - -# @pytest.mark.parametrize("N", Ns) -# def test_t1_2D_forward_CPU(N: int) -> None: -# check_t1_forward(N, 2, "cpu") - - -# @pytest.mark.parametrize("N", Ns) -# def test_t1_2D_forward_cuda(N: int) -> None: -# check_t1_forward(N, 2, "cuda") - - -# #### 3D TESTS #### - -# Ns = [ -# 3, -# 5, -# 10, -# 15, -# 16, -# 25, -# 26, -# 37, -# ] - - -# @pytest.mark.parametrize("N", Ns) -# def test_t1_3D_forward_CPU(N: int) -> None: -# check_t1_forward(N, 3, "cpu") - - -# @pytest.mark.parametrize("N", Ns) -# def test_t1_3D_forward_cuda(N: int) -> None: -# check_t1_forward(N, 3, "cuda") diff --git a/tests/test_t2_backward.py b/tests/test_t2_backward.py index 536cca4..f50ee88 100644 --- a/tests/test_t2_backward.py +++ b/tests/test_t2_backward.py @@ -82,173 +82,3 @@ def test_t2_backward_cuda_points(target_shape, N, fftshift, isign) -> None: @pytest.mark.parametrize("isign", [-1, 1]) def test_t2_backward_cuda_values(target_shape, N, fftshift, isign) -> None: check_t2_backward(target_shape, N, fftshift, isign, "cuda", False) - - -# #### 1D TESTS #### - -# Ns = [ -# 5, -# 8, -# 10, -# 15, -# 16, -# 63, -# ] - -# length_modifiers = [-1, 0, 1, 4] - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t2_1D_backward_CPU_targets( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t2_backward(N, (1, N + modifier), fftshift, isign, "cpu", False) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t2_1D_backward_CPU_points( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t2_backward(N, (1, N + modifier), fftshift, isign, "cpu", True) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t2_1D_backward_cuda_targets( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t2_backward(N, (1, N + modifier), fftshift, isign, "cuda", False) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t2_1D_backward_cuda_points( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t2_backward(N, (1, N + modifier), fftshift, isign, "cuda", True) - - -# #### 2D TESTS #### - -# Ns = [ -# 3, -# # 5, -# # 8, -# # 10, -# # 15, -# # 16, -# ] - -# length_modifiers = [ -# 0, -# 1, -# # 4, -# -1, -# ] - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t1_2D_backward_CPU_targets( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t2_backward(N, (2, N + modifier), fftshift, isign, "cpu", False) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t1_2D_backward_CPU_points( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t2_backward(N, (2, N + modifier), fftshift, isign, "cpu", True) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t1_2D_backward_cuda_targets( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t2_backward(N, (2, N + modifier), fftshift, isign, "cuda", False) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t1_2D_backward_cuda_points( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t2_backward(N, (2, N + modifier), fftshift, isign, "cuda", True) - - -# #### 3D TESTS #### - - -# Ns = [ -# 3, -# # 5, -# # 8, -# ] - -# length_modifiers = [ -# # -1, -# 0, -# 1, -# # 4 -# ] - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t2_3D_backward_CPU_targets( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t2_backward(N, (3, N + modifier), fftshift, isign, "cpu", False) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t2_3D_backward_CPU_points( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t2_backward(N, (3, N + modifier), fftshift, isign, "cpu", True) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t2_3D_backward_cuda_targets( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t2_backward(N, (3, N + modifier), fftshift, isign, "cuda", False) - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("modifier", length_modifiers) -# @pytest.mark.parametrize("fftshift", [False, True]) -# @pytest.mark.parametrize("isign", [-1, 1]) -# def test_t2_3D_backward_cuda_points( -# N: int, modifier: int, fftshift: bool, isign: int -# ) -> None: -# check_t2_backward(N, (3, N + modifier), fftshift, isign, "cuda", True) diff --git a/tests/test_t2_forward.py b/tests/test_t2_forward.py index c62da96..0f8fb76 100644 --- a/tests/test_t2_forward.py +++ b/tests/test_t2_forward.py @@ -70,80 +70,3 @@ def test_t2_forward_CPU(N_and_dim) -> None: def test_t2_forward_cuda(N_and_dim) -> None: N, dim = N_and_dim check_t2_forward(N, dim, "cuda") - - -# #### 1D TESTS #### - -# Ns = [ -# 5, -# 10, -# 15, -# 100, -# 101, -# 1000, -# 1001, -# 3750, -# 5000, -# 5001, -# 6250, -# 7500, -# ] - - -# @pytest.mark.parametrize("N", Ns) -# def test_t2_1D_forward_CPU(N: int) -> None: -# check_t2_forward(N, 1, "cpu") - - -# @pytest.mark.parametrize("N", Ns) -# def test_t2_1D_forward_cuda(N: int) -> None: -# check_t2_forward(N, 1, "cuda") - - -# #### 2D TESTS #### -# Ns = [ -# 3, -# 10, -# 15, -# 75, -# 76, -# 95, -# 96, -# 100, -# 101, -# ] - - -# @pytest.mark.parametrize("N", Ns) -# @pytest.mark.parametrize("fftshift", [False, True]) -# def test_t2_2D_forward_CPU(N: int, fftshift: bool) -> None: -# check_t2_forward(N, 2, "cpu", fftshift) - - -# @pytest.mark.parametrize("N", Ns) -# def test_t2_2D_forward_cuda(N: int) -> None: -# check_t2_forward(N, 2, "cuda") - - -# #### 3D TESTS #### - -# Ns = [ -# 3, -# 5, -# 10, -# 15, -# 16, -# 25, -# 26, -# 37, -# ] - - -# @pytest.mark.parametrize("N", Ns) -# def test_t2_3D_forward_CPU(N: int) -> None: -# check_t2_forward(N, 3, "cpu") - - -# @pytest.mark.parametrize("N", Ns) -# def test_t2_3D_forward_cuda(N: int) -> None: -# check_t2_forward(N, 3, "cuda") From ff2d6cf86487f594068014d9081e5f642daaf315 Mon Sep 17 00:00:00 2001 From: Michael Eickenberg Date: Mon, 23 Oct 2023 13:00:42 -0400 Subject: [PATCH 6/6] TST split test parameters using mark.parametrize instead of within the test --- tests/test_t1_forward.py | 10 ++++------ tests/test_t2_forward.py | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/test_t1_forward.py b/tests/test_t1_forward.py index f5ca7a4..c81e264 100644 --- a/tests/test_t1_forward.py +++ b/tests/test_t1_forward.py @@ -61,13 +61,11 @@ def check_t1_forward(N: int, dim: int, device: str) -> None: ] -@pytest.mark.parametrize("N_and_dim", Ns_and_dims) -def test_t1_forward_CPU(N_and_dim) -> None: - N, dim = N_and_dim +@pytest.mark.parametrize("N, dim", Ns_and_dims) +def test_t1_forward_CPU(N, dim) -> None: check_t1_forward(N, dim, "cpu") -@pytest.mark.parametrize("N_and_dim", Ns_and_dims) -def test_t1_forward_cuda(N_and_dim) -> None: - N, dim = N_and_dim +@pytest.mark.parametrize("N, dim", Ns_and_dims) +def test_t1_forward_cuda(N, dim) -> None: check_t1_forward(N, dim, "cuda") diff --git a/tests/test_t2_forward.py b/tests/test_t2_forward.py index 0f8fb76..43e195b 100644 --- a/tests/test_t2_forward.py +++ b/tests/test_t2_forward.py @@ -60,13 +60,11 @@ def check_t2_forward(N: int, dim: int, device: str, fftshift=False) -> None: ] -@pytest.mark.parametrize("N_and_dim", Ns_and_dims) -def test_t2_forward_CPU(N_and_dim) -> None: - N, dim = N_and_dim +@pytest.mark.parametrize("N, dim", Ns_and_dims) +def test_t2_forward_CPU(N, dim) -> None: check_t2_forward(N, dim, "cpu") -@pytest.mark.parametrize("N_and_dim", Ns_and_dims) -def test_t2_forward_cuda(N_and_dim) -> None: - N, dim = N_and_dim +@pytest.mark.parametrize("N, dim", Ns_and_dims) +def test_t2_forward_cuda(N, dim) -> None: check_t2_forward(N, dim, "cuda")