MCPcopy Index your code
hub / github.com/DevTechJr/turboquant_cutile / test_quantize_nearest_centroid

Function test_quantize_nearest_centroid

tests/test_codebook.py:86–92  ·  view source on GitHub ↗

Values close to a centroid should map to that centroid's index.

()

Source from the content-addressed store, hash-verified

84
85
86def 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()}"

Callers

nothing calls this directly

Calls 2

quantizeMethod · 0.95
LloydMaxCodebookClass · 0.90

Tested by

no test coverage detected