data_transfer / bbflow_base /tests /test_validate_motion_target_cache.py
hanghang214's picture
Add files using upload-large-folder tool
24599ef verified
Raw History Blame Contribute Delete
1.56 kB
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"])