@@ -155,12 +155,14 @@ which can be used to append data to any axis. E.g.::
155
155
compressor: Blosc(cname='lz4', clevel=5, shuffle=1)
156
156
store: dict
157
157
>>> z.append(a)
158
+ (20000, 1000)
158
159
>>> z
159
160
Array((20000, 1000), int32, chunks=(1000, 100), order=C)
160
161
nbytes: 76.3M; nbytes_stored: 3.8M; ratio: 20.3; initialized: 200/200
161
162
compressor: Blosc(cname='lz4', clevel=5, shuffle=1)
162
163
store: dict
163
164
>>> z.append(np.vstack([a, a]), axis=1)
165
+ (20000, 2000)
164
166
>>> z
165
167
Array((20000, 2000), int32, chunks=(1000, 100), order=C)
166
168
nbytes: 152.6M; nbytes_stored: 7.5M; ratio: 20.3; initialized: 400/400
@@ -220,12 +222,12 @@ compression, level 1::
220
222
store: dict
221
223
222
224
Here is an example using LZMA with a custom filter pipeline including
223
- the delta filter::
225
+ LZMA's built-in delta filter::
224
226
225
227
>>> import lzma
226
- >>> filters = [dict(id=lzma.FILTER_DELTA, dist=4),
227
- ... dict(id=lzma.FILTER_LZMA2, preset=1)]
228
- >>> compressor = zarr.LZMA(filters=filters )
228
+ >>> lzma_filters = [dict(id=lzma.FILTER_DELTA, dist=4),
229
+ ... dict(id=lzma.FILTER_LZMA2, preset=1)]
230
+ >>> compressor = zarr.LZMA(filters=lzma_filters )
229
231
>>> z = zarr.array(np.arange(100000000, dtype='i4').reshape(10000, 10000),
230
232
... chunks=(1000, 1000), compressor=compressor)
231
233
>>> z
@@ -234,7 +236,28 @@ the delta filter::
234
236
compressor: LZMA(format=1, check=-1, preset=None, filters=[{'dist': 4, 'id': 3}, {'preset': 1, 'id': 33}])
235
237
store: dict
236
238
237
- To disable compression, set ``compressor=None `` when creating an array.
239
+ The default compressor can be changed by setting the value of the
240
+ ``zarr.storage.default_compressor `` variable, e.g.::
241
+
242
+ >>> import zarr.storage
243
+ >>> # switch to using Zstandard via Blosc by default
244
+ ... zarr.storage.default_compressor = zarr.Blosc(cname='zstd', clevel=1, shuffle=1)
245
+ >>> z = zarr.zeros(100000000, chunks=1000000)
246
+ >>> z
247
+ Array((100000000,), float64, chunks=(1000000,), order=C)
248
+ nbytes: 762.9M; nbytes_stored: 302; ratio: 2649006.6; initialized: 0/100
249
+ compressor: Blosc(cname='zstd', clevel=1, shuffle=1)
250
+ store: dict
251
+ >>> # switch back to Blosc defaults
252
+ ... zarr.storage.default_compressor = zarr.Blosc()
253
+
254
+ To disable compression, set ``compressor=None `` when creating an array, e.g.::
255
+
256
+ >>> z = zarr.zeros(100000000, chunks=1000000, compressor=None)
257
+ >>> z
258
+ Array((100000000,), float64, chunks=(1000000,), order=C)
259
+ nbytes: 762.9M; nbytes_stored: 209; ratio: 3827751.2; initialized: 0/100
260
+ store: dict
238
261
239
262
.. _tutorial_filters :
240
263
@@ -321,8 +344,8 @@ This array is safe to read or write within a multi-threaded program.
321
344
Zarr also provides support for process synchronization via file locking,
322
345
provided that all processes have access to a shared file system. E.g.::
323
346
324
- >>> synchronizer = zarr.ProcessSynchronizer('example.zarr ')
325
- >>> z = zarr.open_array('example.zarr ', mode='w', shape=(10000, 10000),
347
+ >>> synchronizer = zarr.ProcessSynchronizer('example.sync ')
348
+ >>> z = zarr.open_array('example', mode='w', shape=(10000, 10000),
326
349
... chunks=(1000, 1000), dtype='i4',
327
350
... synchronizer=synchronizer)
328
351
>>> z
0 commit comments