Quantize → dequantize should map each centroid exactly to itself.
()
| 76 | |
| 77 | |
| 78 | def test_roundtrip_identity(): |
| 79 | """Quantize → dequantize should map each centroid exactly to itself.""" |
| 80 | cb = LloydMaxCodebook(128, 3) |
| 81 | indices = torch.arange(cb.n_levels) |
| 82 | reconstructed = cb.dequantize(indices) |
| 83 | assert torch.allclose(reconstructed, cb.centroids, atol=1e-6) |
| 84 | |
| 85 | |
| 86 | def test_quantize_nearest_centroid(): |
nothing calls this directly
no test coverage detected