Download bbflow_base/tests/test_validate_motion_target_cache.py from hanghang214/data_transfer: direct link, hf CLI and curl.
- Browser
- Download file 1.56 kB
-
https://huggingface.co/datasets/hanghang214/data_transfer/resolve/main/bbflow_base/tests/test_validate_motion_target_cache.py
- Command line
-
hf download hf://datasets/hanghang214/data_transfer/bbflow_base/tests/test_validate_motion_target_cache.py
-
curl -L -o test_validate_motion_target_cache.py https://huggingface.co/datasets/hanghang214/data_transfer/resolve/main/bbflow_base/tests/test_validate_motion_target_cache.py
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"]) | |