Skip to content

Commit 3e7c70e

Browse files
committed
simplify codecs config for dtypes
1 parent 9c0a265 commit 3e7c70e

File tree

2 files changed

+10
-44
lines changed

2 files changed

+10
-44
lines changed

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])

zarr/tests/test_core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,12 +505,12 @@ def test_np_ufuncs(self):
505505

506506
# use zarr array as indices or condition
507507
zc = self.create_array(shape=condition.shape, dtype=condition.dtype,
508-
chunks=10)
508+
chunks=10, filters=None)
509509
zc[:] = condition
510510
assert_array_equal(np.compress(condition, a, axis=0),
511511
np.compress(zc, a, axis=0))
512512
zi = self.create_array(shape=indices.shape, dtype=indices.dtype,
513-
chunks=10)
513+
chunks=10, filters=None)
514514
zi[:] = indices
515515
assert_array_equal(np.take(a, indices, axis=1),
516516
np.take(a, zi, axis=1))

0 commit comments

Comments
 (0)