Values close to a centroid should map to that centroid's index.
()
| 84 | |
| 85 | |
| 86 | def test_quantize_nearest_centroid(): |
| 87 | """Values close to a centroid should map to that centroid's index.""" |
| 88 | cb = LloydMaxCodebook(128, 2) |
| 89 | for i, c in enumerate(cb.centroids): |
| 90 | test_val = c + 1e-6 |
| 91 | idx = cb.quantize(test_val.unsqueeze(0)) |
| 92 | assert idx.item() == i, f"Expected index {i}, got {idx.item()}" |
nothing calls this directly
no test coverage detected