MCPcopy Create free account
hub / github.com/alibaba/zvec / check

Function check

python/tests/test_uniform_quantization_support_matrix.py:123–146  ·  view source on GitHub ↗
(count, trained)

Source from the content-addressed store, hash-verified

121 collection = zvec.create_and_open(path=path, schema=schema)
122
123 def check(count, trained):
124 persisted_param = collection.schema.vectors[0].index_param
125 assert persisted_param.quantize_type == quantizer
126 assert persisted_param.to_dict()["quantize_type"] == quantizer.name
127 hits = collection.query(
128 zvec.Query(
129 "dense", vector=query_vector.tolist(), param=query_type(is_linear=True)
130 ),
131 topk=count,
132 )
133 assert len(hits) == count
134 assert {hit.id for hit in hits} == {str(i) for i in range(count)}
135 for hit in hits:
136 i = int(hit.id)
137 expected = quant_scores[i] if i < trained else raw_scores[i]
138 assert hit.score == pytest.approx(float(expected), rel=2e-5, abs=2e-5)
139 # Also check normal graph search, independently of the exhaustive scan.
140 for i in (0, count - 1):
141 nearest = collection.query(
142 zvec.Query("dense", vector=vectors[i].tolist(), param=query_type()),
143 topk=1,
144 )
145 assert nearest[0].id == str(i)
146 assert nearest[0].score == pytest.approx(0.0, abs=1e-5)
147
148 try:
149 assert all(

Callers 1

Calls 1

queryMethod · 0.45

Tested by

no test coverage detected