@@ -44,8 +44,10 @@ Design goals
44
44
Usage
45
45
-----
46
46
47
- Create an array::
47
+ Create an array:
48
48
49
+ .. code-block ::
50
+
49
51
>>> import numpy as np
50
52
>>> import zarr
51
53
>>> z = zarr.empty(shape=(10000, 1000), dtype='i4', chunks=(1000, 100))
@@ -54,16 +56,20 @@ Create an array::
54
56
cname: blosclz; clevel: 5; shuffle: 1 (BYTESHUFFLE)
55
57
nbytes: 38.1M; cbytes: 0; initialized: 0/100
56
58
57
- Fill it with some data::
59
+ Fill it with some data:
58
60
61
+ .. code-block ::
62
+
59
63
>>> z[:] = np.arange(10000000, dtype='i4').reshape(10000, 1000)
60
64
>>> z
61
65
zarr.ext.SynchronizedArray((10000, 1000), int32, chunks=(1000, 100))
62
66
cname: blosclz; clevel: 5; shuffle: 1 (BYTESHUFFLE)
63
67
nbytes: 38.1M; cbytes: 2.0M; ratio: 19.3; initialized: 100/100
64
68
65
- Obtain a NumPy array by slicing::
69
+ Obtain a NumPy array by slicing:
66
70
71
+ .. code-block ::
72
+
67
73
>>> z[:]
68
74
array([[ 0, 1, 2, ..., 997, 998, 999],
69
75
[ 1000, 1001, 1002, ..., 1997, 1998, 1999],
@@ -89,8 +95,10 @@ Obtain a NumPy array by slicing::
89
95
[9998000, 9998001, 9998002, ..., 9998097, 9998098, 9998099],
90
96
[9999000, 9999001, 9999002, ..., 9999097, 9999098, 9999099]], dtype=int32)
91
97
92
- Resize the array and add more data::
98
+ Resize the array and add more data:
93
99
100
+ .. code-block ::
101
+
94
102
>>> z.resize(20000, 1000)
95
103
>>> z
96
104
zarr.ext.SynchronizedArray((20000, 1000), int32, chunks=(1000, 100))
@@ -123,9 +131,9 @@ append data to any axis:
123
131
Persistence
124
132
-----------
125
133
126
- Create a persistent array (data stored on disk)
134
+ Create a persistent array (data stored on disk):
127
135
128
- .. code-block :: python
136
+ .. code-block ::
129
137
130
138
>>> path = 'example.zarr'
131
139
>>> z = zarr.open(path, mode='w', shape=(10000, 1000), dtype='i4', chunks=(1000, 100))
@@ -139,9 +147,9 @@ Create a persistent array (data stored on disk)
139
147
There is no need to close a persistent array. Data are automatically flushed
140
148
to disk.
141
149
142
- If you're working with really big arrays, try the 'lazy' option
150
+ If you're working with really big arrays, try the 'lazy' option:
143
151
144
- .. code-block :: python
152
+ .. code-block ::
145
153
146
154
>>> path = 'big.zarr'
147
155
>>> z = zarr.open(path, mode='w', shape=(1e8, 1e7), dtype='i4', chunks=(1000, 1000), lazy=True)
0 commit comments