(self)
| 182 | assert text_vector[i] == doc.vectors["text"][i] |
| 183 | |
| 184 | def test_with_sparse_vector_fields(self): |
| 185 | schema = CollectionSchema( |
| 186 | name="test_collection", |
| 187 | vectors=[ |
| 188 | VectorSchema( |
| 189 | name="author", |
| 190 | data_type=DataType.SPARSE_VECTOR_FP32, |
| 191 | ), |
| 192 | VectorSchema( |
| 193 | name="content", |
| 194 | data_type=DataType.SPARSE_VECTOR_FP16, |
| 195 | ), |
| 196 | ], |
| 197 | ) |
| 198 | doc = Doc( |
| 199 | id="1", |
| 200 | vectors={ |
| 201 | "author": {1: 1.1, 2: 2.2, 3: 3.3}, |
| 202 | "content": {4: 4.4, 5: 5.5, 6: 6.6}, |
| 203 | }, |
| 204 | ) |
| 205 | |
| 206 | cpp_doc = convert_to_cpp_doc(doc, collection_schema=schema) |
| 207 | assert cpp_doc is not None |
| 208 | assert cpp_doc.pk() == doc.id |
| 209 | |
| 210 | author_vector = cpp_doc.get_any("author", DataType.SPARSE_VECTOR_FP32) |
| 211 | assert isinstance(author_vector, dict) |
| 212 | for key, value in doc.vector("author").items(): |
| 213 | assert math.isclose(author_vector[key], value, rel_tol=1e-1) |
| 214 | |
| 215 | content_vector = cpp_doc.get_any("content", DataType.SPARSE_VECTOR_FP16) |
| 216 | assert isinstance(content_vector, dict) |
| 217 | for key, value in doc.vector("content").items(): |
| 218 | assert math.isclose(content_vector[key], value, rel_tol=1e-1) |
| 219 | |
| 220 | def test_with_scalar_fields_error_datatype(self): |
| 221 | schema = CollectionSchema( |
nothing calls this directly
no test coverage detected