Download bbflow_base/tests/test_template_upper_bound.py from hanghang214/data_transfer: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/datasets/hanghang214/data_transfer/resolve/main/bbflow_base/tests/test_template_upper_bound.py
- Command line
-
hf download hf://datasets/hanghang214/data_transfer/bbflow_base/tests/test_template_upper_bound.py
-
curl -L -o test_template_upper_bound.py https://huggingface.co/datasets/hanghang214/data_transfer/resolve/main/bbflow_base/tests/test_template_upper_bound.py
1.01 kB
| import torch | |
| from scripts.fit_motion_template_upper_bound import covariance_from_modes, remove_rigid_component | |
| def test_remove_rigid_component_removes_translation_and_rotation(): | |
| coords = torch.tensor([ | |
| [-1.0, -1.0, 0.0], | |
| [1.0, -1.0, 0.0], | |
| [1.0, 1.0, 0.0], | |
| [-1.0, 1.0, 0.0], | |
| ]) | |
| mask = torch.ones(4) | |
| omega = torch.tensor([0.0, 0.0, 2.0]) | |
| translation = torch.tensor([0.5, -0.25, 0.75]) | |
| rigid = torch.cross(omega[None, :].expand_as(coords), coords, dim=-1) + translation[None, :] | |
| u = rigid[:, None, :] | |
| cleaned = remove_rigid_component(u, coords, mask, remove_rotation=True) | |
| assert cleaned.abs().max() < 1e-4 | |
| def test_covariance_from_modes_expresses_anti_correlation(): | |
| u = torch.tensor([ | |
| [[1.0, 0.0, 0.0]], | |
| [[-1.0, 0.0, 0.0]], | |
| ]) | |
| energy = torch.tensor([2.0]) | |
| _, cross_cov, _ = covariance_from_modes(u, energy) | |
| assert cross_cov[0, 1] < 0 | |
| assert torch.isclose(cross_cov[0, 1], torch.tensor(-2.0)) | |