We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 86b03f3 commit a0470c0Copy full SHA for a0470c0
tests/unit/test_pydantic.py
@@ -111,3 +111,17 @@ def test_match_to_from_pydantic():
111
assert da_r[0].matches[0].scores['cosine']
112
assert isinstance(da_r[0].matches[0].scores, defaultdict)
113
assert isinstance(da_r[0].matches[0].scores['random_score'], NamedScore)
114
+
115
116
+def test_pydantic_from_dict_ndarray():
117
+ from docarray import Document
118
+ import numpy as np
119
+ doc = Document()
120
+ doc.embedding = np.random.rand(2, 2)
121
+ pydantic_model1 = doc.to_pydantic_model()
122
+ assert len(pydantic_model1.embedding) == 2
123
+ for emb_dim in pydantic_model1.embedding:
124
+ assert len(emb_dim) == 2
125
+ pydantic_model2 = PydanticDocument(**doc.to_dict())
126
+ print(pydantic_model2.embedding)
127
0 commit comments