Skip to content

Commit abf2b21

Browse files
authored
Merge pull request #73 from alimanfoo/v2.1.1-dev
V2.1.1 dev
2 parents 4905332 + 9cdfe49 commit abf2b21

File tree

12 files changed

+529
-210
lines changed

12 files changed

+529
-210
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,4 @@ zarr/version.py
6868
*.zip
6969
example*
7070
doesnotexist
71+
test_sync*

docs/release.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
Release notes
22
=============
33

4+
.. _release_2.1.1:
5+
6+
2.1.1
7+
-----
8+
9+
Various minor improvements, including: ``Group`` objects support member access
10+
via dot notation (``__getattr__``); fixed metadata caching for ``Array.shape``
11+
property and derivatives; added ``Array.ndim`` property; fixed
12+
``Array.__array__`` method arguments; fixed bug in pickling ``Array`` state;
13+
fixed bug in pickling ``ThreadSynchronizer``.
14+
415
.. _release_2.1.0:
516

617
2.1.0

docs/tutorial.rst

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,14 @@ which can be used to append data to any axis. E.g.::
155155
compressor: Blosc(cname='lz4', clevel=5, shuffle=1)
156156
store: dict
157157
>>> z.append(a)
158+
(20000, 1000)
158159
>>> z
159160
Array((20000, 1000), int32, chunks=(1000, 100), order=C)
160161
nbytes: 76.3M; nbytes_stored: 3.8M; ratio: 20.3; initialized: 200/200
161162
compressor: Blosc(cname='lz4', clevel=5, shuffle=1)
162163
store: dict
163164
>>> z.append(np.vstack([a, a]), axis=1)
165+
(20000, 2000)
164166
>>> z
165167
Array((20000, 2000), int32, chunks=(1000, 100), order=C)
166168
nbytes: 152.6M; nbytes_stored: 7.5M; ratio: 20.3; initialized: 400/400
@@ -220,12 +222,12 @@ compression, level 1::
220222
store: dict
221223

222224
Here is an example using LZMA with a custom filter pipeline including
223-
the delta filter::
225+
LZMA's built-in delta filter::
224226

225227
>>> 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)
229231
>>> z = zarr.array(np.arange(100000000, dtype='i4').reshape(10000, 10000),
230232
... chunks=(1000, 1000), compressor=compressor)
231233
>>> z
@@ -234,7 +236,28 @@ the delta filter::
234236
compressor: LZMA(format=1, check=-1, preset=None, filters=[{'dist': 4, 'id': 3}, {'preset': 1, 'id': 33}])
235237
store: dict
236238

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
238261

239262
.. _tutorial_filters:
240263

@@ -321,8 +344,8 @@ This array is safe to read or write within a multi-threaded program.
321344
Zarr also provides support for process synchronization via file locking,
322345
provided that all processes have access to a shared file system. E.g.::
323346

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),
326349
... chunks=(1000, 1000), dtype='i4',
327350
... synchronizer=synchronizer)
328351
>>> z

zarr/codecs.py

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
from zarr.compat import text_type, binary_type
15-
from zarr.meta import encode_dtype, decode_dtype
1615

1716

1817
codec_registry = dict()
@@ -471,16 +470,10 @@ def decode(self, buf, out=None):
471470
def get_config(self):
472471
config = dict()
473472
config['id'] = self.codec_id
474-
config['dtype'] = encode_dtype(self.dtype)
475-
config['astype'] = encode_dtype(self.astype)
473+
config['dtype'] = self.dtype.str
474+
config['astype'] = self.astype.str
476475
return config
477476

478-
@classmethod
479-
def from_config(cls, config):
480-
dtype = decode_dtype(config['dtype'])
481-
astype = decode_dtype(config['astype'])
482-
return cls(dtype=dtype, astype=astype)
483-
484477
def __repr__(self):
485478
r = '%s(dtype=%s' % (type(self).__name__, self.dtype)
486479
if self.astype != self.dtype:
@@ -595,21 +588,12 @@ def decode(self, buf, out=None):
595588
def get_config(self):
596589
config = dict()
597590
config['id'] = self.codec_id
598-
config['astype'] = encode_dtype(self.astype)
599-
config['dtype'] = encode_dtype(self.dtype)
591+
config['astype'] = self.astype.str
592+
config['dtype'] = self.dtype.str
600593
config['scale'] = self.scale
601594
config['offset'] = self.offset
602595
return config
603596

604-
@classmethod
605-
def from_config(cls, config):
606-
astype = decode_dtype(config['astype'])
607-
dtype = decode_dtype(config['dtype'])
608-
scale = config['scale']
609-
offset = config['offset']
610-
return cls(astype=astype, dtype=dtype, scale=scale,
611-
offset=offset)
612-
613597
def __repr__(self):
614598
r = '%s(scale=%s, offset=%s, dtype=%s' % \
615599
(type(self).__name__, self.scale, self.offset, self.dtype)
@@ -702,17 +686,10 @@ def get_config(self):
702686
config = dict()
703687
config['id'] = self.codec_id
704688
config['digits'] = self.digits
705-
config['dtype'] = encode_dtype(self.dtype)
706-
config['astype'] = encode_dtype(self.astype)
689+
config['dtype'] = self.dtype.str
690+
config['astype'] = self.astype.str
707691
return config
708692

709-
@classmethod
710-
def from_config(cls, config):
711-
dtype = decode_dtype(config['dtype'])
712-
astype = decode_dtype(config['astype'])
713-
digits = config['digits']
714-
return cls(digits=digits, dtype=dtype, astype=astype)
715-
716693
def __repr__(self):
717694
r = '%s(digits=%s, dtype=%s' % \
718695
(type(self).__name__, self.digits, self.dtype)
@@ -806,10 +783,6 @@ def get_config(self):
806783
config['id'] = self.codec_id
807784
return config
808785

809-
@classmethod
810-
def from_config(cls, config):
811-
return cls()
812-
813786
def __repr__(self):
814787
r = '%s()' % type(self).__name__
815788
return r
@@ -921,17 +894,10 @@ def get_config(self):
921894
config = dict()
922895
config['id'] = self.codec_id
923896
config['labels'] = [_ensure_text(l) for l in self.labels]
924-
config['dtype'] = encode_dtype(self.dtype)
925-
config['astype'] = encode_dtype(self.astype)
897+
config['dtype'] = self.dtype.str
898+
config['astype'] = self.astype.str
926899
return config
927900

928-
@classmethod
929-
def from_config(cls, config):
930-
dtype = decode_dtype(config['dtype'])
931-
astype = decode_dtype(config['astype'])
932-
labels = config['labels']
933-
return cls(labels=labels, dtype=dtype, astype=astype)
934-
935901
def __repr__(self):
936902
# make sure labels part is not too long
937903
labels = repr(self.labels[:3])

0 commit comments

Comments
 (0)