Skip to content

Commit

Permalink
TST tests passing for forward type 1 3d consolidated
Browse files Browse the repository at this point in the history
  • Loading branch information
eickenberg committed Oct 5, 2023
1 parent edacea0 commit 2b3ac0f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/test_3d/test_forward_3d.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 All @@ -13,8 +14,6 @@
25,
26,
37,
100,
101,
]


Expand Down Expand Up @@ -106,8 +105,13 @@ def test_t1_forward_CPU(N: int) -> None:
(N, N, N),
)

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

assert abs((finufft_out - against_torch).sum()) / N**3 == 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 < 1.5e-5 * N ** 1.5
assert l_2_error < 1e-5 * N ** 3
assert l_1_error < 1e-5 * N ** 4.5

0 comments on commit 2b3ac0f

Please sign in to comment.