MCPcopy
hub / github.com/redis/redis-py / test_vemb_bin_quantization

Function test_vemb_bin_quantization

tests/test_vsets.py:554–569  ·  view source on GitHub ↗
(d_client)

Source from the content-addressed store, hash-verified

552
553@skip_if_server_version_lt("7.9.0")
554def test_vemb_bin_quantization(d_client):
555 e = [1, 4.32, 0.0, 0.05, -2.9]
556 d_client.vset().vadd(
557 "myset",
558 e,
559 "elem",
560 quantization=QuantizationOptions.BIN,
561 )
562 emb_no_quant = d_client.vset().vemb("myset", "elem")
563 assert emb_no_quant == [1, 1, -1, 1, -1]
564
565 emb_no_quant_raw = d_client.vset().vemb("myset", "elem", raw=True)
566 assert emb_no_quant_raw["quantization"] == "bin"
567 assert isinstance(emb_no_quant_raw["raw"], bytes)
568 assert isinstance(emb_no_quant_raw["l2"], float)
569 assert "range" not in emb_no_quant_raw
570
571
572@skip_if_server_version_lt("7.9.0")

Callers

nothing calls this directly

Calls 3

vaddMethod · 0.80
vembMethod · 0.80
vsetMethod · 0.45

Tested by

no test coverage detected