Skip to content

Commit

Permalink
TST test for forward type 1 passing in 2D, also fixed random seed
Browse files Browse the repository at this point in the history
  • Loading branch information
eickenberg committed Oct 5, 2023
1 parent 745c343 commit edacea0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/test_2d/test_forward_2d.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import pytest
import torch
torch.manual_seed(0)

import pytorch_finufft

Expand Down Expand Up @@ -144,6 +145,12 @@ def test_t1_forward_CPU(N: int) -> None:

against_torch = torch.fft.fft2(values.reshape(g[0].shape))

assert (finufft_out - against_torch) == pytest.approx(
0, abs=1e-6
)
abs_errors = torch.abs(finufft_out - against_torch)
l_inf_error = abs_errors.max()
l_2_error = torch.sqrt(torch.sum(abs_errors**2))
l_1_error = torch.sum(abs_errors)

assert l_inf_error < 4.5e-5 * N
assert l_2_error < 1e-5 * N ** 2
assert l_1_error < 1e-5 * N ** 3

0 comments on commit edacea0

Please sign in to comment.