File size: 1,560 Bytes
24599ef | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | import pytest
import torch
from bbflow.data.alignment import ALIGNMENT_VERSION
from scripts.validate_motion_target_cache import validate_cache
def test_validate_cache_rejects_missing_required_mean(tmp_path):
path = tmp_path / "old.pt"
torch.save(
{
"alignment_version": ALIGNMENT_VERSION,
"motion_targets": {
"1abcA": {"local_cov": torch.zeros(1, 3, 3)}
},
},
path,
)
with pytest.raises(ValueError, match="oracle_mean_disp"):
validate_cache(path, ["local_cov", "oracle_mean_disp"])
def test_validate_cache_accepts_complete_targets(tmp_path):
path = tmp_path / "new.pt"
torch.save(
{
"alignment_version": ALIGNMENT_VERSION,
"motion_targets": {
"1abcA": {
"local_cov": torch.zeros(1, 3, 3),
"oracle_mean_disp": torch.zeros(1, 3),
}
}
},
path,
)
assert validate_cache(path, ["local_cov", "oracle_mean_disp"]) == 1
def test_validate_cache_rejects_legacy_alignment_version(tmp_path):
path = tmp_path / "legacy.pt"
torch.save(
{
"motion_targets": {
"1abcA": {
"local_cov": torch.zeros(1, 3, 3),
"oracle_mean_disp": torch.zeros(1, 3),
}
}
},
path,
)
with pytest.raises(ValueError, match="alignment_version"):
validate_cache(path, ["local_cov", "oracle_mean_disp"])
|