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

Method test_with_numpy_array

python/tests/test_doc.py:67–85  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

65 assert doc.field("weight") == 60.5
66
67 def test_with_numpy_array(self):
68 import numpy as np
69
70 doc = Doc._from_tuple(
71 (
72 "1",
73 0.0,
74 None,
75 {
76 "image": np.array([1, 2, 3]),
77 "description": np.random.random(512),
78 "keys": {1: 1.0, 2: 2.0, 3: 3.0},
79 },
80 )
81 )
82 assert doc is not None
83 assert doc.id == "1"
84 assert doc.vector("image") == [1, 2, 3]
85 assert doc.vector("keys") == {1: 1.0, 2: 2.0, 3: 3.0}
86
87 def test_init_normalizes_numpy_vectors(self):
88 import numpy as np

Callers

nothing calls this directly

Calls 2

_from_tupleMethod · 0.80
vectorMethod · 0.45

Tested by

no test coverage detected