@@ -41,7 +41,9 @@ Design goals
41
41
Usage
42
42
-----
43
43
44
- Create an array::
44
+ Create an array
45
+
46
+ .. code-block :: python
45
47
46
48
>> > import numpy as np
47
49
>> > import zarr
@@ -51,15 +53,19 @@ Create an array::
51
53
cname: blosclz; clevel: 5 ; shuffle: 1 (BYTESHUFFLE )
52
54
nbytes: 38. 1M ; cbytes: 0 ; initialized: 0 / 100
53
55
54
- Fill it with some data::
56
+ Fill it with some data
57
+
58
+ .. code-block :: python
55
59
56
60
>> > z[:] = np.arange(10000000 , dtype = ' i4' ).reshape(10000 , 1000 )
57
61
>> > z
58
62
zarr.ext.SynchronizedArray((10000 , 1000 ), int32, chunks = (1000 , 100 ))
59
63
cname: blosclz; clevel: 5 ; shuffle: 1 (BYTESHUFFLE )
60
64
nbytes: 38. 1M ; cbytes: 2. 0M ; ratio: 19.3 ; initialized: 100 / 100
61
65
62
- Obtain a NumPy array by slicing::
66
+ Obtain a NumPy array by slicing
67
+
68
+ .. code-block :: python
63
69
64
70
>> > z[:]
65
71
array([[ 0 , 1 , 2 , ... , 997 , 998 , 999 ],
@@ -86,7 +92,9 @@ Obtain a NumPy array by slicing::
86
92
[9998000 , 9998001 , 9998002 , ... , 9998097 , 9998098 , 9998099 ],
87
93
[9999000 , 9999001 , 9999002 , ... , 9999097 , 9999098 , 9999099 ]], dtype = int32)
88
94
89
- Resize the array and add more data::
95
+ Resize the array and add more data
96
+
97
+ .. code-block :: python
90
98
91
99
>> > z.resize(20000 , 1000 )
92
100
>> > z
@@ -100,7 +108,9 @@ Resize the array and add more data::
100
108
nbytes: 76. 3M ; cbytes: 4. 0M ; ratio: 19.3 ; initialized: 200 / 200
101
109
102
110
For convenience, an ``append() `` method is also available, which can be used to
103
- append data to any axis::
111
+ append data to any axis
112
+
113
+ .. code-block :: python
104
114
105
115
>> > a = np.arange(10000000 , dtype = ' i4' ).reshape(10000 , 1000 )
106
116
>> > z = zarr.array(a, chunks = (1000 , 100 ))
@@ -119,7 +129,9 @@ append data to any axis::
119
129
cname: blosclz; clevel: 5 ; shuffle: 1 (BYTESHUFFLE )
120
130
nbytes: 152. 6M ; cbytes: 7. 6M ; ratio: 20.2 ; initialized: 400 / 400
121
131
122
- Create a persistent array (data stored on disk)::
132
+ Create a persistent array (data stored on disk)
133
+
134
+ .. code-block :: python
123
135
124
136
>> > path = ' example.zarr'
125
137
>> > z = zarr.open(path, shape = (10000 , 1000 ), dtype = ' i4' , chunks = (1000 , 100 ))
@@ -133,7 +145,9 @@ Create a persistent array (data stored on disk)::
133
145
There is no need to close a persistent array. Data are automatically flushed
134
146
to disk.
135
147
136
- If you're working with really big arrays, try the 'lazy' option::
148
+ If you're working with really big arrays, try the 'lazy' option
149
+
150
+ .. code-block :: python
137
151
138
152
>> > path = ' big.zarr'
139
153
>> > z = zarr.open(path, shape = (1e8 , 1e7 ), dtype = ' i4' , chunks = (1000 , 1000 ), lazy = True )
0 commit comments