Skip to content

Commit

Permalink
add test for craft ground truth theta
Browse files Browse the repository at this point in the history
  • Loading branch information
misko committed Oct 27, 2024
1 parent 818de70 commit d5c7bd5
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions tests/test_fake_data.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import tempfile

import numpy as np

import tempfile

import pytest

import torch

from spf.dataset.fake_dataset import create_fake_dataset, fake_yaml
from spf.dataset.spf_dataset import v5spfdataset

import numpy as np

from spf.utils import identical_datasets


Expand Down Expand Up @@ -79,6 +73,25 @@ def test_fake_data_array_orientation():
assert np.isclose(ds.ground_truth_phis[0], ds.mean_phase["r0"], atol=0.001).all()
assert np.isclose(ds.ground_truth_phis[1], ds.mean_phase["r1"], atol=0.001).all()

# test craft ground truth theta
tx_pos = torch.vstack(
[
torch.tensor([ds[idx][0]["tx_pos_x_mm"], ds[idx][0]["tx_pos_y_mm"]])
for idx in range(len(ds))
]
)
rx_pos = torch.vstack(
[
torch.tensor([ds[idx][0]["rx_pos_x_mm"], ds[idx][0]["rx_pos_y_mm"]])
for idx in range(len(ds))
]
)
craft_theta = torch.tensor(
[torch.tensor(ds[idx][0]["craft_ground_truth_theta"]) for idx in range(len(ds))]
)
d = tx_pos - rx_pos
assert torch.arctan2(d[:, 0], d[:, 1]).isclose(craft_theta, rtol=0.0001).all()


def test_identical_datasets():
with tempfile.TemporaryDirectory() as tmpdirname:
Expand Down

0 comments on commit d5c7bd5

Please sign in to comment.