docarray.document.mixins.convert module#
- class docarray.document.mixins.convert.ConvertMixin[source]#
Bases:
objectProvide helper functions for
Documentto support conversion betweentensor,textandblob.- convert_blob_to_tensor(dtype=None, count=-1, offset=0)[source]#
Assuming the
blobis a _valid_ buffer of Numpy ndarray, settensoraccordingly.- Parameters:
dtype (
Optional[str]) – Data-type of the returned array; default: float.count (
int) – Number of items to read.-1means all data in the buffer.offset (
int) – Start reading the buffer from this offset (in bytes); default: 0.
- Return type:
T
- Returns:
itself after processed
- convert_tensor_to_blob()[source]#
Convert
tensortoblobinplace.- Return type:
T
- Returns:
itself after processed
- convert_uri_to_datauri(charset='utf-8', base64=False)[source]#
Convert
urito dataURI and store it inuriinplace.- Parameters:
charset (
str) – charset may be any character set registered with IANAbase64 (
bool) – used to encode arbitrary octet sequences into a form that satisfies the rules of 7bit. Designed to be efficient for non-text 8 bit and binary data. Sometimes used for text data that frequently uses non-US-ASCII characters.
- Return type:
T
- Returns:
itself after processed