You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/fundamentals/document/construct.md
+13-3Lines changed: 13 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,19 @@ d = Document()
15
15
<Document ('id',) at 5dd542406d3f11eca3241e008a366d49>
16
16
```
17
17
18
-
Every Document will have a unique random `id` that helps you identify this Document. It can be used to {ref}`access this Document inside a DocumentArray<access-elements>`. You can override this `id` or assign your own `id` during construction, as demonstrated below.
18
+
Every Document will have a unique random `id` that helps you identify this Document. It can be used to {ref}`access this Document inside a DocumentArray<access-elements>`.
19
+
20
+
````{tip}
21
+
The random `id` is the hex value of [UUID1](https://docs.python.org/3/library/uuid.html#uuid.uuid1). To convert it into the string of UUID:
22
+
23
+
```python
24
+
import uuid
25
+
str(uuid.UUID(d.id))
26
+
```
27
+
````
28
+
29
+
Though possible, it is not recommended modifying `.id` of a Document frequently, as this will lead to unexpected behavior.
30
+
19
31
20
32
## Construct with attributes
21
33
@@ -25,7 +37,6 @@ This is the most common usage of the constructor: initializing a Document object
25
37
from docarray import Document
26
38
import numpy
27
39
28
-
d0 = Document(id='my_id')
29
40
d1 = Document(text='hello')
30
41
d2 = Document(buffer=b'\f1')
31
42
d3 = Document(blob=numpy.array([1, 2, 3]))
@@ -43,7 +54,6 @@ Don't forget to leverage autocomplete in your IDE.
43
54
```
44
55
45
56
```text
46
-
<Document ('id',) at my_id>
47
57
<Document ('id', 'mime_type', 'text') at a14effee6d3e11ec8bde1e008a366d49>
48
58
<Document ('id', 'buffer') at a14f00986d3e11ec8bde1e008a366d49>
49
59
<Document ('id', 'blob') at a14f01a66d3e11ec8bde1e008a366d49>
Copy file name to clipboardExpand all lines: docs/get-started/what-is.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,7 +91,7 @@ As one can see, you can convert a DocumentArray into AwkwardArray via `.to_list(
91
91
92
92
[Zarr](https://zarr.readthedocs.io/en/stable/) is a format for the storage of chunked, compressed, N-dimensional arrays. I know Zarr quite long time ago, to me it is the package when a `numpy.ndarray` is so big to fit into memory. Zarr provides a comprehensive set of functions that allows one to chunk, compress, stream large NdArray. Hence, from that perspective, Zarr like `numpy.ndarray` focuses on numerical representation and computation.
93
93
94
-
In DocArray, the basic element one would work with is a Document, not `ndarray`. The support of `ndarray` is important, but not the full story: in the context of deep learning engineering, it is often an intermediate representation of Document for computing, then being thrown away. Therefore, having a consistent data structure that can live *long enough* to cover creating, storing, computing, transferring, returning and rendering is a motivation behind DocArray.
94
+
In DocArray, the basic element one would work with is a Document, not `ndarray`. The support of `ndarray` is important, but not the full story: in the context of deep learning engineering, `ndarray` is often an intermediate representation of Document for computing, then throw away. Therefore, having a consistent data structure that lives *long enough* to cover creating, storing, computing, transferring, returning and rendering is one of the major motivations of DocArray.
0 commit comments