Download tests/infoflow/test_residual_cache.py from mmmmmcyaaa/ReTime: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/mmmmmcyaaa/ReTime/resolve/main/tests/infoflow/test_residual_cache.py
- Command line
-
hf download hf://mmmmmcyaaa/ReTime/tests/infoflow/test_residual_cache.py
-
curl -L -o test_residual_cache.py https://huggingface.co/mmmmmcyaaa/ReTime/resolve/main/tests/infoflow/test_residual_cache.py
1.24 kB
| import numpy as np | |
| import pytest | |
| from starVLA.scoring.residual_cache import ( | |
| interpolate_grid_scores, | |
| percentile_intensity_masses, | |
| quantile_anchor_positions, | |
| ) | |
| def test_quantile_grid_is_unique_and_covers_endpoints(): | |
| positions = quantile_anchor_positions(101, 8) | |
| assert len(positions) == 8 | |
| assert positions[0] == 0 | |
| assert positions[-1] == 100 | |
| assert np.all(np.diff(positions) > 0) | |
| def test_quantile_grid_uses_every_short_episode_anchor(): | |
| np.testing.assert_array_equal(quantile_anchor_positions(3, 8), [0, 1, 2]) | |
| def test_interpolation_preserves_grid_values(): | |
| positions = np.asarray([0, 2, 4]) | |
| scores = np.asarray([0.0, 2.0, 0.0]) | |
| interpolated = interpolate_grid_scores(5, positions, scores) | |
| np.testing.assert_allclose(interpolated, [0.0, 1.0, 2.0, 1.0, 0.0]) | |
| def test_interpolation_requires_endpoint_coverage(): | |
| with pytest.raises(ValueError, match="endpoints"): | |
| interpolate_grid_scores(5, np.asarray([1, 4]), np.asarray([0.0, 1.0])) | |
| def test_percentile_masses_have_floor_and_preserve_order(): | |
| masses = percentile_intensity_masses( | |
| np.asarray([5.0, 1.0, 3.0]), | |
| epsilon=0.1, | |
| ) | |
| np.testing.assert_allclose(masses, [1.1, 0.1, 0.6]) | |