Download bbflow_base/tests/test_sample_condition_probe.py from hanghang214/data_transfer: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/datasets/hanghang214/data_transfer/resolve/main/bbflow_base/tests/test_sample_condition_probe.py
- Command line
-
hf download hf://datasets/hanghang214/data_transfer/bbflow_base/tests/test_sample_condition_probe.py
-
curl -L -o test_sample_condition_probe.py https://huggingface.co/datasets/hanghang214/data_transfer/resolve/main/bbflow_base/tests/test_sample_condition_probe.py
1.09 kB
| import torch | |
| from scripts.probe_sample_condition import sample_coefficient_condition | |
| def test_sample_coefficient_condition_preserves_adapter_shapes_and_scales_modes(): | |
| condition = { | |
| "node_cond": torch.tensor([[[2.0, 3.0], [4.0, 5.0]]]), | |
| "edge_cond": torch.tensor([[[[7.0, 11.0], [13.0, 17.0]], [[19.0, 23.0], [29.0, 31.0]]]]), | |
| "energy": torch.tensor([[4.0, 9.0]]), | |
| } | |
| eps = torch.tensor([[2.0, -3.0]]) | |
| sampled = sample_coefficient_condition(condition, eps, coefficient_scale=0.5) | |
| expected_coeff = torch.tensor([[1.0, -1.5]]) | |
| assert sampled["node_cond"].shape == condition["node_cond"].shape | |
| assert sampled["edge_cond"].shape == condition["edge_cond"].shape | |
| assert torch.allclose(sampled["mode_eps"], expected_coeff) | |
| assert torch.allclose(sampled["node_cond"], condition["node_cond"] * expected_coeff[:, None, :]) | |
| assert torch.allclose(sampled["edge_cond"], condition["edge_cond"] * expected_coeff[:, None, None, :].square()) | |
| assert torch.allclose(condition["node_cond"], torch.tensor([[[2.0, 3.0], [4.0, 5.0]]])) | |