In the spirit of pydantic, a model (document) field that is annotated with a certain type should only ever hold data that is actually of that type.
To achieve that, incoming data of a different type should be coerced to the target type.
This does not happen between DocList and DocVec:
from docarray import BaseDoc, DocList, DocVec
from docarray.documents import ImageDoc
class Doc(BaseDoc):
docs: DocList[ImageDoc]
d = Doc(docs=DocVec[ImageDoc]([ImageDoc()]))
# below should give <DocList[ImageDoc] (length=1)> but give <DocVec[ImageDoc] (length=1)>
print(d.docs)
class OtherDoc(BaseDoc):
docs: DocVec[ImageDoc]
d = Doc(docs=DocList[ImageDoc]([ImageDoc()]))
# below should give <DocVec[ImageDoc] (length=1)> but give <DocList[ImageDoc] (length=1)>
print(d.docs)
In the spirit of pydantic, a model (document) field that is annotated with a certain type should only ever hold data that is actually of that type.
To achieve that, incoming data of a different type should be coerced to the target type.
This does not happen between
DocListandDocVec: