Skip to content

Commit

Permalink
TST add mode ordering to type2 forward test 2d
Browse files Browse the repository at this point in the history
  • Loading branch information
eickenberg committed Oct 12, 2023
1 parent 1aed7e2 commit c329e01
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/test_2d/test_forward_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ def test_2d_t2_forward_CPU(N: int) -> None:


@pytest.mark.parametrize("N", Ns)
def test_t2_forward_CPU(N: int) -> None:
@pytest.mark.parametrize("fftshift", [False, True])
def test_t2_forward_CPU(N: int, fftshift: bool) -> None:
"""
Tests against implementations of the FFT by setting up a uniform grid
over which to call FINUFFT through the API.
Expand All @@ -131,9 +132,14 @@ def test_t2_forward_CPU(N: int) -> None:
finufft_out = pytorch_finufft.functional.finufft_type2.apply(
points,
targets,
None,
{'modeord': int(not fftshift)},
)

against_torch = torch.fft.fft2(targets)
if fftshift:
against_torch = torch.fft.fft2(torch.fft.ifftshift(targets))
else:
against_torch = torch.fft.fft2(targets)

abs_errors = torch.abs(finufft_out - against_torch.ravel())
l_inf_error = abs_errors.max()
Expand Down

0 comments on commit c329e01

Please sign in to comment.